package com.dp.service.impl3;

import java.sql.ResultSetMetaData;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.persistence.Query;

import org.springframework.stereotype.Service;

import com.dp.pojo.TjAdaccessbyareaVo;
import com.dp.pojo.TjChannelaccessVo;
import com.dp.pojo.TjConstopbyareaVo;
import com.dp.pojo.TjK16adscalltimeVo;
import com.dp.pojo.TjK16appaccessVo;
import com.dp.pojo.TTjK16LinkTimeVo;
import com.dp.pojo.TjIphoneDay;
import com.dp.pojo.TjK16avgtimeVo;
import com.dp.pojo.TjK16browsertimeVo;
import com.dp.pojo.TjK16receivefileVo;
import com.dp.pojo.TjMsgarrivalVo;
import com.dp.pojo.TjShareuseVo;
import com.dp.pub.Page;
import com.dp.util.DataMap;
import com.dp.util.InterUtil;
import com.dp.vo.TAreainfo;
import com.dp.vo.TChannels;
import com.dp.vo.TDownloadlog;
import com.dp.vo.TTjAdsAccess;
import com.dp.vo.TTjChannelsAccess;
import com.dp.vo.TTjChsAccessByPlatform;
import com.dp.vo.TTjConsAccessByPlatform;
import com.dp.vo.TTjIncomingbyarea;
import com.dp.vo.TTjIncomingbycontent;
import com.dp.vo.TTjInoutuser;
import com.dp.vo.TTjK16LinkTime;
import com.dp.vo.TTjMobile;
import com.dp.vo.TTjNewUser;
import com.dp.vo.TTjPltfmActUser;
import com.dp.vo.TTjPortalContents;
import com.dp.vo.TTjSp;
import com.dp.vo.TTjTopTwenty;
import com.dp.vo.TTjUsernumber;
import com.dp.vo.TTjWapUserOrder;

@Service
public class ReportServiceImpl3 extends BaseImpl {
    public static String whoami;
    static{
    	whoami=""+System.currentTimeMillis();    	
    }

    public List<TTjIncomingbyarea> findIA(String year) {
    	List<TTjIncomingbyarea> t=new ArrayList<TTjIncomingbyarea>();
    	TTjIncomingbyarea temp=null;
    	try {
		
    	this.sql="select upareaid,ifnull(upareaname,'notset') as upareaname , ifnull(pricetype,'notset') as pricetype ,cmonth,sum(incoming) as incoming from t_tj_incomingbyarea a" +
    			" where a.cyear='"+year+"' group by upareaid,upareaname,pricetype,cmonth " +
    			" order by  upareaid,upareaname,pricetype,cmonth ";
    	List<Object[]> tempp=this.em.createNativeQuery(sql).getResultList();
		for(Object[]o:tempp)
		{
    	   temp=new TTjIncomingbyarea();
    	   temp.setUpareaname(this.getString(o[1]));
    	   temp.setPricetype(this.getString(o[2]));
    	   temp.setCmonth(this.getString(o[3]));
    	   temp.setIncoming(this.getInteger(o[4]));  
    	   t.add(temp);
    	}    	
    	} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
    	
        return t;
    }
    public List<TTjIncomingbycontent> findIC(String year) {
    	List<TTjIncomingbycontent> t=new ArrayList<TTjIncomingbycontent>();
    	TTjIncomingbycontent temp=null;
    	try {
		
		
    	this.sql=" select  ifnull(ctype,'notset') as ctype ,ifnull(pricetype,'notset') as pricetype,cmonth,sum(incoming) as incoming from t_tj_incomingbycontent" +
    			" where cyear='"+year+"' group by ctype,pricetype,cmonth    order by  ctype,pricetype,cmonth";
    	List<Object[]> tempp=this.em.createNativeQuery(sql).getResultList();
		for(Object[]o:tempp)
		{
    	   temp=new TTjIncomingbycontent();
    	   temp.setCtype(this.getString(o[0]));
    	   temp.setPricetype(this.getString(o[1]));
    	   temp.setCmonth(this.getString(o[2]));
    	   temp.setIncoming(this.getInteger(o[3]));
    	   t.add(temp);
    	}    	
    	} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
    	
        return t;
    }
    public List<TTjSp> findSP(String... year) {
    	List<TTjSp> t=new ArrayList<TTjSp>();
    	TTjSp temp=null;
    	try {
			
		   switch(year.length)
		   {
		   case 3:
			   this.sql=" select  ifnull(spname,'notset') as spname  , ifnull(sname,'notset') as sname    ,chour,sum(downloadnumber) as dd,sum(ordernumber) as od from t_tj_sp " +
   			            "  where cyear='"+year[0]+"' and cmonth='"+year[1]+"' and cday='"+year[2]+"'  group by spname,sname,chour";
			   break;
		   case 2:
			   this.sql=" select  ifnull(spname,'notset') as spname  , ifnull(sname,'notset') as sname  ,cday,sum(downloadnumber) as dd,sum(ordernumber) as od from t_tj_sp " +
		            "  where cyear='"+year[0]+"' and cmonth='"+year[1]+"'  group by spname,sname,cday";
			   break;
		   case 1:
			   this.sql=" select  ifnull(spname,'notset') as spname  , ifnull(sname,'notset') as sname  ,cmonth,sum(downloadnumber) as dd,sum(ordernumber) as od from t_tj_sp " +
	            "  where cyear='"+year[0]+"'  group by spname,sname,cmonth";		  
			   break;
		   default:
			   break;
		   
		   }
		   List<Object[]> tempp=this.em.createNativeQuery(sql).getResultList();
			for(Object[]o:tempp)
			{
    	   temp=new TTjSp();
    	   temp.setSpname(this.getString(o[0]));
    	   temp.setSname(this.getString(o[1]));
    	   temp.setCmonth(this.getString(o[2]));
    	   temp.setDownloadnumber(this.getInteger(o[3]));
    	   temp.setOrdernumber(this.getInteger(o[4]));
    	   t.add(temp);
    	}    	
    	} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
    	
        return t;
    }
    
    //----------------------------1221 get wap user order province------------------------
    public List<TTjWapUserOrder> getTTjWapUserOrderWithProvince(Map<String,String> idAndNameMap,String... year)
    {
    	List<TTjWapUserOrder> t=new ArrayList<TTjWapUserOrder>();
    	TTjWapUserOrder temp=null;
    	try {
			
			switch(year.length)
			{
			   case 2:
				   this.sql=" select contentid,day(createtime),count(*),tmp.province,sercvice_code from t_user_order tuo," +
				   		"t_mobile_province tmp where year(createtime)="+year[0]+" and month(createtime)="+year[1];
				   //订购类型2包月 订购来源1 wap
				   this.sql += " and ordertype=2 and ordersource=1";
				   //关联t_mobile_province
				   this.sql += " and tuo.phonenum=tmp.mobile";
				   //按省分组
				   this.sql += " group by contentid,tmp.province";
				   break;
			   case 1:
				   this.sql=" select contentid,month(createtime),count(*),tmp.province,sercvice_code from t_user_order tuo," +
			            "t_mobile_province tmp where year(createtime)="+year[0];
				   this.sql += " and ordertype=2 and ordersource=1";
				   this.sql += " and tuo.phonenum=tmp.mobile";
				   this.sql += " group by contentid,tmp.province";
				   break;
			   default:
				   break;
			}
			logger.info("getTTjWapUserOrderWithProvince excute: " +sql);
			List<Object[]> tempp=this.em.createNativeQuery(sql).getResultList();
			for(Object[]o:tempp)
			{
	    	   temp=new TTjWapUserOrder();
	    	   String cname = idAndNameMap.get(this.getString(o[0]));
	    	   if(cname == null || "".equals(cname))
	    		   continue;
	    	   temp.setContentname(cname);
	    	   temp.setCmonth(this.getString(o[1]));
	    	   temp.setOrdernumber(this.getInteger(o[2]));
	    	   temp.setProvince(this.getString(o[3]));
	    	   t.add(temp);
	    	}    	
    	} catch (Exception e) {
			e.printStackTrace();
		}
    	
        return t;
    }
    
    public List<String> getAllProvinceForMobileProvince()
    {
    	List<String> t=new ArrayList<String>();
    	String temp=null;
    	try {
			
			this.sql="SELECT distinct province FROM t_mobile_province t";
			List<Object[]> tempp=this.em.createNativeQuery(sql).getResultList();
			for(Object[]o:tempp)
			{
	    		temp =this.getString(o[0]);
	    		if(temp != null && !"".equals(temp))
	    			t.add(temp);
	    	}    	
    	} catch (Exception e) {
			e.printStackTrace();
		}
    
        return t;
    }
    
    //----------------------------1217 get wap user order------------------------
    public List<TTjWapUserOrder> getTTjWapUserOrder(Map<String,String> idAndNameMap,String... year)
    {
    	List<TTjWapUserOrder> t=new ArrayList<TTjWapUserOrder>();
    	TTjWapUserOrder temp=null;
    	try {
		
			switch(year.length)
			{
			   case 2:
				   this.sql=" select contentid,day(createtime),count(*),sercvice_code from t_user_order  " +
	   			    " where year(createtime)="+year[0]+" and month(createtime)="+year[1];
				   //订购类型2包月 订购来源1 wap
				   this.sql += " and ordertype=2 and ordersource=1";
				   this.sql += " group by contentid,day(createtime)";
				   break;
			   case 1:
				   this.sql=" select contentid,month(createtime),count(*),sercvice_code from t_user_order " +
			            " where year(createtime)="+year[0];
				   this.sql += " and ordertype=2 and ordersource=1";
				   this.sql += " group by contentid,month(createtime)";
				   break;
			   default:
				   break;
			}
			logger.info("getTTjWapUserOrder excute: " +sql);
			List<Object[]> tempp=this.em.createNativeQuery(sql).getResultList();
			for(Object[]o:tempp)
			{
	    	   temp=new TTjWapUserOrder();
	    	   String cname = idAndNameMap.get(this.getString(o[0]));
	    	   if(cname == null || "".equals(cname))
	    		   continue;
	    	   temp.setContentname(cname);
	    	   temp.setCmonth(this.getString(o[1]));
	    	   temp.setOrdernumber(this.getInteger(o[2]));
	    	   t.add(temp);
	    	}    	
    	} catch (Exception e) {
			e.printStackTrace();
		}
    
        return t;
    }
    
    //----------------------------1013 portal content access build hdnews channel list------------------------
    public Map<String,String> buildHdnewsChannelList(String hdnewsrootch)
    {
    	Map<String,String> resultMap = null;
    	this.sql = "select channel_id,channel_name from t_channels where previous_id='"+hdnewsrootch+"'" +
    			"and channel_type='hdnews' and channel_classifying_label is not null";
    	try {
	
			resultMap = new HashMap<String,String>();
			List<TChannels> firstChList = new ArrayList<TChannels>();
			List<Object[]> tempp=this.em.createNativeQuery(sql).getResultList();
			for(Object[]o:tempp)
			{
				TChannels tmp = new TChannels();
				tmp.setChannelId(this.getString(o[0]));
				tmp.setChannelName(this.getString(o[1]));
				firstChList.add(tmp);
			}
			//遍历一级普通栏目
			for(TChannels one : firstChList)
			{
				String lastChidStr = "";
				List<Integer> secChIdList = new ArrayList<Integer>();
				this.sql = "select nef.channelid from t_channels tc,news_extends_firstchannel nef " +
					"where tc.previous_id='"+one.getChannelId()+"' and tc.channel_id=nef.channel_id";
				 tempp=this.em.createNativeQuery(sql).getResultList();
					for(Object[]o:tempp)
					{
					//Integer channelid = rs2.getInt(1);
					secChIdList.add(this.getInteger(o[0]));
				}
				for(Integer chintid : secChIdList)
				{
					//最后一级 经典美食-快乐厨房-美食DIY...
					this.sql = "select nefc.channleid from news_extends_firstchannel_channels nefc where nefc.channelid="+chintid;
					 tempp=this.em.createNativeQuery(sql).getResultList();
						for(Object[]o:tempp)
						{
						Integer lastid = this.getInteger(o[0]);
						lastChidStr += lastid + ",";
					}
				}
				if(lastChidStr.endsWith(","))
					lastChidStr = lastChidStr.substring(0, lastChidStr.length()-1);
				//map key:一级普通栏目名称 value:最后一级栏目id string
				resultMap.put(one.getChannelName(), lastChidStr);
			}
		}  catch (Exception e) {
			e.printStackTrace();
		}    	
	
    	return resultMap;
    }
    
    
    //----------------------------1012 portal content access------------------------
    public List<TTjPortalContents> findTTjHdPortalContentsAccess(String userids,String titleKeyWrd,
    		String newstype,String firstchannelid,String... year)
    {
    	List<TTjPortalContents> t=new ArrayList<TTjPortalContents>();
    	TTjPortalContents temp=null;
    	try {
			
			switch(year.length)
			{
			   case 2:
				   this.sql=" SELECT contenttitle,cday,accessnumber FROM t_tj_toptwenty t where " +
	   			    " cyear='"+year[0]+"' and cmonth='"+year[1]+"' ";
				   
				   if(titleKeyWrd != null && titleKeyWrd.length()>0)
					   this.sql += " and contenttitle like '%"+titleKeyWrd+"%'";
				   if(newstype != null && newstype.length()>0)
					   this.sql += " and newstype = '"+newstype+"'";
				   //按栏目查询
				   if(firstchannelid != null && firstchannelid.length()>0)
				   {
					   sql = sql.replace("FROM t_tj_toptwenty t", "FROM t_tj_toptwenty t,news_extends_channel_title n");
					   sql += " and t.cid=n.cid and n.channleid in ("+firstchannelid+")";
				   }
				   if(userids != null && userids.length()>0)
					   this.sql += " and user_id in ("+userids+")";
				   break;
			   case 1:
				   this.sql=" SELECT contenttitle,cmonth,sum(accessnumber) FROM t_tj_toptwenty t " +
			            "  where cyear='"+year[0]+"' ";
				   if(titleKeyWrd != null && titleKeyWrd.length()>0)
					   this.sql += " and contenttitle like '%"+titleKeyWrd+"%'";
				   if(newstype != null && newstype.length()>0)
					   this.sql += " and newstype = '"+newstype+"'";
				   //按栏目查询
				   if(firstchannelid != null && firstchannelid.length()>0)
				   {
					   sql = sql.replace("FROM t_tj_toptwenty t", "FROM t_tj_toptwenty t,news_extends_channel_title n");
					   sql += " and t.cid=n.cid and n.channleid in ("+firstchannelid+")";
				   }
				   if(userids != null && userids.length()>0)
					   this.sql += " and user_id in ("+userids+")";
				   this.sql += " group by t.cid,cmonth";
				   break;
			   default:
				   break;
			}
			logger.info("findTTjHdPortalContentsAccess excute: " +sql);
			List<Object[]> tempp=this.em.createNativeQuery(sql).getResultList();
			for(Object[]o:tempp)
			{
	    	   temp=new TTjPortalContents();
	    	   temp.setContenttitle(this.getString(o[0]));
	    	   temp.setCmonth(this.getString(o[1]));
	    	   temp.setAccessnumber(this.getInteger(o[0]));
	    	   t.add(temp);
	    	}    	
    	} catch (Exception e) {
			e.printStackTrace();
		}
    
        return t;
    }
    
    //----------------------------0825 active user------------------------
    public List<TTjPltfmActUser> getTTjActiveUser(String platformflag,String... year)
    {
    	List<TTjPltfmActUser> t=new ArrayList<TTjPltfmActUser>();
    	TTjPltfmActUser temp=null;
    	try {
			
			switch(year.length)
			{
			   case 2:
				   this.sql=" select count(a.a),a.cday from (select count(id) a,cday cday from t_tj_pltfmactuser " +
				   		"where cyear='"+year[0]+"' and cmonth='"+year[1]+"' group by cday,udid) a group by a.cday";
				   if(platformflag != null && "1".equals(platformflag))
					   this.sql = "select count(a.a),a.cday,a.mpaltform from (select count(id) a,udid,mpaltform mpaltform,cday cday from " +
					   	"t_tj_pltfmactuser where cyear='"+year[0]+"' and cmonth='"+year[1]+"' group by cday,udid) a group by a.cday,a.mpaltform";
				   break;
			   case 1:
				   this.sql=" select count(a.a),a.cmonth from (select count(id) a,cmonth cmonth from t_tj_pltfmactuser " +
			   		"where cyear='"+year[0]+"' group by cmonth,udid) a group by a.cmonth";
			   if(platformflag != null && "1".equals(platformflag))
				   this.sql = "select count(a.a),a.cmonth,a.mpaltform from (select count(id) a,mpaltform mpaltform,cmonth cmonth from " +
				   	"t_tj_pltfmactuser where cyear='"+year[0]+"' group by cmonth,udid) a group by a.cmonth,a.mpaltform";
			   break;
			   default:
				   break;
			}
			logger.info("getTTjActiveUser excute: " +sql);
			List<Object[]> tempp=this.em.createNativeQuery(sql).getResultList();
			for(Object[]o:tempp)
			{
	    		
	    	   temp=new TTjPltfmActUser();
	    	   temp.setUsernumber(this.getInteger(o[0]));
	    	   temp.setCmonth(this.getString(o[1]));
	    	   if(platformflag != null && "1".equals(platformflag))
	    		   temp.setMpaltform(this.getString(o[2]));
	    	   t.add(temp);
	    	}    	
    	} catch (Exception e) {
			e.printStackTrace();
		}
   
        return t;
    }
    
    //----------------------------0820 hd portal channel access------------------------
    public List<TTjChannelsAccess> getTTjHdPortalChannelsAccess(String empids,String newstype,String... year) {
    	List<TTjChannelsAccess> t=new ArrayList<TTjChannelsAccess>();
    	TTjChannelsAccess temp=null;
    	try {
			
			switch(year.length)
			{
			   case 2:
				   this.sql=" SELECT ch_name,cday,accessnumber FROM t_tj_channelsaccess t,t_channels tc " +
	   			    " where cyear='"+year[0]+"' and cmonth='"+year[1]+"'";
	   			   //add channel type 
				   if(newstype != null && newstype.length()>0)
					   this.sql += " and tc.channel_type='"+newstype+"'";
				   else
					   this.sql += " and (tc.channel_type='hdnews' or tc.channel_type='yellowpage') ";
				   this.sql += " and t.channel_id=tc.channel_id";
				   
				   if(empids != null && empids.length()>0)
					   this.sql += " and t.channel_id in (select channel_id from t_user_channels where employee_id in ("+empids+"))";
				   break;
			   case 1:
				   this.sql=" SELECT ch_name,cmonth,sum(accessnumber) a FROM t_tj_channelsaccess t,t_channels tc " +
			            " where cyear='"+year[0]+"'";
				   //add channel type 
				   if(newstype != null && newstype.length()>0)
					   this.sql += " and tc.channel_type='"+newstype+"'";
				   else
					   this.sql += " and (tc.channel_type='hdnews' or tc.channel_type='yellowpage') ";
				   this.sql += " and t.channel_id=tc.channel_id";
				   
				   if(empids != null && empids.length()>0)
					   this.sql += " and t.channel_id in (select channel_id from t_user_channels where employee_id in ("+empids+"))";
				   this.sql += " group by t.channel_id,cmonth order by a desc,cmonth";
				   break;
			   default:
				   break;
			}
			logger.info("findTTjChannelsAccess excute: " +sql);
			List<Object[]> tempp=this.em.createNativeQuery(sql).getResultList();
			for(Object[]o:tempp)
			{
	    	   temp=new TTjChannelsAccess();
	    	   temp.setCh_name(this.getString(o[0]));
	    	   temp.setCmonth(this.getString(o[1]));
	    	   temp.setAccessnumber(this.getInteger(o[2]));
	    	   t.add(temp);
	    	}    	
    	} catch (Exception e) {
			e.printStackTrace();
		}
    	
        return t;
    }
    
    //----------------------------0819 wap down------------------------
    public List<TDownloadlog> getTjForWapDown(String userids,String... year) {
    	List<TDownloadlog> t=new ArrayList<TDownloadlog>();
    	TDownloadlog temp=null;
    	try {
			
			switch(year.length)
			{
			//flag=3 will be change
			   case 2:
				   this.sql="SELECT nc.contenttitle,td.contentid,count(td.contentid) a,day(td.downloadtime) FROM t_downloadlog td," +
				   	"news_contenttitle nc where year(downloadtime)='"+year[0]+"' and month(downloadtime)='"+year[1]+"' " +
				   	"and td.flag=3 and td.contentid=nc.cid " +
	   			    " group by td.contentid,day(td.downloadtime) order by a desc,day(td.downloadtime)";
				   if(userids != null && userids.length()>0)
					   this.sql="SELECT nc.contenttitle,td.contentid,count(td.contentid) a,day(td.downloadtime) FROM t_downloadlog td," +
					   	"t_contents tc,news_contenttitle nc where year(downloadtime)='"+year[0]+"' and month(downloadtime)='"+year[1]+"' " +
					   	"and td.flag=3 and tc.user_id in ("+userids+") and td.contentid=nc.cid and nc.contentid=tc.contentid" +
		   			    " group by td.contentid,day(td.downloadtime) order by a desc,day(td.downloadtime)";
				   break;
			   case 1:
				   this.sql="SELECT nc.contenttitle,td.contentid,count(td.contentid) a,month(td.downloadtime) FROM t_downloadlog td," +
				   	"news_contenttitle nc where year(downloadtime)='"+year[0]+"' " +
				   	"and td.flag=3 and td.contentid=nc.cid " +
	   			    " group by td.contentid,month(td.downloadtime) order by a desc,month(td.downloadtime)";
				   if(userids != null && userids.length()>0)
					   this.sql="SELECT nc.contenttitle,td.contentid,count(td.contentid) a,month(td.downloadtime) FROM t_downloadlog td," +
					   	"t_contents tc,news_contenttitle nc where year(downloadtime)='"+year[0]+"' " +
					   	"and td.flag=3 and tc.user_id in ("+userids+") and td.contentid=nc.cid and nc.contentid=tc.contentid" +
		   			    " group by td.contentid,month(td.downloadtime) order by a desc,month(td.downloadtime)";
				   break;
			   default:
				   break;
			}
			logger.info("getTjForWapDown excute: " +sql);
			List<Object[]> tempp=this.em.createNativeQuery(sql).getResultList();
			for(Object[]o:tempp)
			{
	    	   temp=new TDownloadlog();
	    	   //mobile保存title
	    	   temp.setMobile(this.getString(o[0]));
	    	   //flag存下载数
	    	   temp.setFlag(Integer.valueOf(this.getString(o[2])));
	    	   //用id存日期
	    	   temp.setId(Long.valueOf(this.getString(o[3])));
	    	   t.add(temp);
	    	}    	
    	} catch (Exception e) {
			e.printStackTrace();
		}
    
        return t;
    }
    
    
    //----------------------------0819 iphone day------------------------
    public List<TjIphoneDay> getTjForIphoneDay(String... year) {
    	List<TjIphoneDay> t=new ArrayList<TjIphoneDay>();
    	TjIphoneDay temp=null;
    	try {
			
			switch(year.length)
			{
			   case 2:
				   this.sql="SELECT title_episode_season,vendor_identifier,sum(units),day(begin_date) FROM news_tj_iphone_day n " +
	   			    " where year(begin_date)='"+year[0]+"' and month(begin_date)='"+year[1]+"' " +
	   			    " group by title_episode_season,begin_date order by title_episode_season,begin_date";
				   break;
			   case 1:
				   this.sql="SELECT title_episode_season,vendor_identifier,sum(units),month(begin_date) FROM news_tj_iphone_day n " +
	   			    " where year(begin_date)='"+year[0]+"' " +
	   			    " group by title_episode_season,month(begin_date) order by title_episode_season,month(begin_date)";
				   break;
			   default:
				   break;
			}
			logger.info("getTjForIphoneDay excute: " +sql);
			List<Object[]> tempp=this.em.createNativeQuery(sql).getResultList();
			for(Object[]o:tempp)
			{
	    	   temp=new TjIphoneDay();
	    	   temp.setTitle_episode_season(this.getString(o[0]));
	    	   temp.setVendor_identifier(this.getString(o[1]));
	    	   temp.setUnits(Integer.valueOf(this.getString(o[2])));
	    	   //用id存日期
	    	   temp.setId(Integer.valueOf(this.getString(o[3])));
	    	   t.add(temp);
	    	}    	
    	} catch (Exception e) {
			e.printStackTrace();
		}
    	
        return t;
    }
    
    //add 1025 get all areaname
    public List<TAreainfo> getTAreainfoForK16LinkTime()
    {
    	List<TAreainfo> t=new ArrayList<TAreainfo>();
    	TAreainfo temp=null;
    	try {
			
//			this.sql="select ta.areaid,ta.areaname from t_areainfo ta";
			this.sql="select t.areaname from t_tj_k16linktime t where t.areaname is not null group by areaname";
			List<Object[]> tempp=this.em.createNativeQuery(sql).getResultList();
			for(Object[]o:tempp)
			{
	    		temp = new TAreainfo();
//	    		temp.setAreaid(rs1.getInt(1));
	    		temp.setAreaname(this.getString(o[0]));
	    		t.add(temp);
	    	}    	
    	} catch (Exception e) {
			e.printStackTrace();
		}
    	
        return t;
    }
    
    //----------------------------1224 k16 link time new------------------------
    //map key=mencoding+kdnumber+areaname value=map<month,linktime>
    public List<TTjK16LinkTimeVo> getTjForK16ConnectCountNew(Map<String,Map<String,Integer>> k16AndLinktimeMap,String sn,String k16sn,String k16phonenumber,
    		String k16buytime1,String k16buytime2,String kdnumber,String areaid,String usertype,Page page,boolean isCount,String... year)
    {
    	//加数据权限 通过传递的SN集合判断用户能够取得的数据
		List<TTjK16LinkTimeVo> t=new ArrayList<TTjK16LinkTimeVo>();
		TTjK16LinkTimeVo temp=null;
//    	try {
//			
//			switch(year.length)
//			{
//			   case 2:
//				   this.sql="select * from (SELECT IFNULL(t.mencoding,'unknown'),t.telnumber,IFNULL(t.kdnumber,''),t.createtime,t.areaname,t.user_type," +
//				   		"t.cday,sum(t.linktime) a,tt.banknumber,tt.servernumber,tt.callcenter,tt.callarea,tt.yyt,tt.servertx,tt.serveraction,tt.priceaction,tt.productname,tt.cname,tt.jx,tt.cstatus,tt.pricename,tt.oktime,tt.note,tt.cempname,tt.caddress,tt.qqh,tt.relationnumber,tt.serverarea,tt.serverqy,tt.xzq,tt.cinfo,tt.ckeyword,tt.creleation,tt.fzman,tt.fzdepartment,tt.validtime,tt.notvalidtime,tt.groupnote,tt.kdsl FROM t_tj_k16linktime t,t_tel_device tt where t.mencoding=tt.devicesn and t.cyear='"+year[0]+"' and t.cmonth='"+year[1]+"' ";
//				   if(k16sn != null && !"".equals(k16sn))
//					   this.sql += " and t.mencoding like '%"+k16sn+"%'";
//				   if(k16phonenumber != null && !"".equals(k16phonenumber))
//					   this.sql += " and t.telnumber like '%"+k16phonenumber+"%'";
//				   if(k16buytime1 != null && !"".equals(k16buytime1))
//					   this.sql += " and t.createtime > '"+k16buytime1+"'";
//				   if(k16buytime2 != null && !"".equals(k16buytime2))
//					   this.sql += " and t.createtime < '"+k16buytime2+"'";
//				   //add kdnumber
//				   if(kdnumber != null && !"".equals(kdnumber))
//					   this.sql += " and t.kdnumber like '%"+kdnumber+"%'";
//				   //add usertype area
//				   if(areaid != null && !"".equals(areaid))
//					   this.sql += " and t.areaname='"+areaid+"'";
//				   if(usertype != null && !"".equals(usertype))
//					   this.sql += " and t.user_type='"+usertype+"'";
//				   if(sn != null && sn.length()>0)
//					   this.sql += " and t.mencoding in ("+sn+")";
//				   this.sql += " group by t.mencoding,t.kdnumber,t.areaname,t.cday ) a";
//				   break;
//			   case 1:
//				   this.sql=" SELECT IFNULL(t.mencoding,'unknown'),t.telnumber,IFNULL(t.kdnumber,''),t.createtime,t.areaname,t.user_type," +
//				   		"t.cmonth,sum(t.linktime) a,tt.banknumber,tt.servernumber,tt.callcenter,tt.callarea,tt.yyt,tt.servertx,tt.serveraction,tt.priceaction,tt.productname,tt.cname,tt.jx,tt.cstatus,tt.pricename,tt.oktime,tt.note,tt.cempname,tt.caddress,tt.qqh,tt.relationnumber,tt.serverarea,tt.serverqy,tt.xzq,tt.cinfo,tt.ckeyword,tt.creleation,tt.fzman,tt.fzdepartment,tt.validtime,tt.notvalidtime,tt.groupnote,tt.kdsl FROM t_tj_k16linktime t,t_tel_device tt where t.mencoding=tt.devicesn and t.cyear='"+year[0]+"' ";
//				   if(k16sn != null && !"".equals(k16sn))
//					   this.sql += " and t.mencoding like '%"+k16sn+"%'";
//				   if(k16phonenumber != null && !"".equals(k16phonenumber))
//					   this.sql += " and t.telnumber like '%"+k16phonenumber+"%'";
//				   if(k16buytime1 != null && !"".equals(k16buytime1))
//					   this.sql += " and t.createtime > '"+k16buytime1+"'";
//				   if(k16buytime2 != null && !"".equals(k16buytime2))
//					   this.sql += " and t.createtime < '"+k16buytime2+"'";
//				   //add kdnumber
//				   if(kdnumber != null && !"".equals(kdnumber))
//					   this.sql += " and t.kdnumber like '%"+kdnumber+"%'";
//				   //add usertype area
//				   if(areaid != null && !"".equals(areaid))
//					   this.sql += " and t.areaname='"+areaid+"'";
//				   if(usertype != null && !"".equals(usertype))
//					   this.sql += " and t.user_type='"+usertype+"'";
//				   if(sn != null && sn.length()>0)
//					   this.sql += " and t.mencoding in ("+sn+")";
//				   this.sql += " group by t.mencoding,t.cmonth ) a";
//				   break;
//			   default:
//				   break;
//			}
//			if(!isCount){
//				sql+=" limit "+((Integer.parseInt(page.getPageno())-1)*Integer.parseInt(page.getRowppage()))+","+Integer.parseInt(page.getRowppage());
//			}
//			logger.info("getTjForK16ConnectCount excute: " +sql);
//			List<Object[]> tempp=this.em.createNativeQuery(sql).getResultList();
//			for(Object[]o:tempp)
//			{
//	    	   temp=new TTjK16LinkTimeVo();
//	    	   String mencodingone = this.getString(o[0]);
//	    	   String kdnumberone = this.getString(o[2]);
//	    	   String areanameone = rs1.getString(5);
//	    	   String cmonthone = rs1.getString(7);
//	    	   Integer linktimeone = rs1.getInt(8);
//	    	   temp.setMencoding(mencodingone);
//	    	   temp.setTelnumber(rs1.getString(2));
//	    	   temp.setKdnumber(kdnumberone);
//	    	   temp.setCreatetime(rs1.getDate(4));
//	    	   temp.setAreaname(areanameone);
//	    	   temp.setUser_type(rs1.getInt(6));
//	    	   temp.setCmonth(cmonthone);
//	    	   temp.setLinktime(linktimeone);
//	    	   temp.setBanknumber(rs1.getString(9));
//	    	   temp.setServernumber(rs1.getString(10));
//	    	   temp.setCallcenter(rs1.getString(11));
//	    	   temp.setCallarea(rs1.getString(12));
//	    	   temp.setYyt(rs1.getString(13));
//	    	   temp.setServertx(rs1.getString(14));
//	    	   temp.setServeraction(rs1.getString(15));
//	    	   temp.setPriceaction(rs1.getString(16));
//	    	   temp.setProductname(rs1.getString(17));
//	    	   temp.setCname(rs1.getString(18));
//	    	   temp.setJx(rs1.getString(19));
//	    	   temp.setCstatus(rs1.getString(20));
//	    	   temp.setPricename(rs1.getString(21));
//	    	   temp.setOktime(rs1.getDate(22));
//	    	   temp.setNote(rs1.getString(23));
//	    	   temp.setCempname(rs1.getString(24));
//	    	   temp.setCaddress(rs1.getString(25));
//	    	   temp.setQqh(rs1.getString(26));
//	    	   temp.setRelationnumber(rs1.getString(27));
//	    	   temp.setServerarea(rs1.getString(28));
//	    	   temp.setServerqy(rs1.getString(29));
//	    	   temp.setXzq(rs1.getString(30));
//	    	   temp.setCinfo(rs1.getString(31));
//	    	   temp.setCkeyword(rs1.getString(32));
//	    	   temp.setCreleation(rs1.getString(33));
//	    	   temp.setFzman(rs1.getString(34));
//	    	   temp.setFzdepartment(rs1.getString(35));
//	    	   temp.setValidtime(rs1.getDate(36));
//	    	   temp.setNotvalidtime(rs1.getDate(37));
//	    	   temp.setGroupnote(rs1.getString(38));
//	    	   temp.setKdsl(rs1.getString(39));
//	    	   
//	    	   t.add(temp);
//	    	   
//	    	   String k16OneKey = mencodingone+"&"+kdnumberone+"&"+areanameone;
//	    	   Map<String,Integer> monthAndLinkTimeMap = new HashMap<String,Integer>();
//	    	   //从map中取k16string对应的map 如果有值则在此map上put
//	    	   if(k16AndLinktimeMap.get(k16OneKey) != null)
//	    	   {
//	    		   monthAndLinkTimeMap = k16AndLinktimeMap.get(k16OneKey);
//	    		   monthAndLinkTimeMap.put(cmonthone, linktimeone);
//	    	   }
//	    	   else
//	    	   {
//	    		   monthAndLinkTimeMap.put(cmonthone, linktimeone);
//	    	   }
//	    	   k16AndLinktimeMap.put(k16OneKey, monthAndLinkTimeMap);
//	    	   
//	    	}    	
//    	} catch (Exception e) {
//			e.printStackTrace();
//		}
//    	
        return t;
    }
    
    
    //----------------------------1224 k16 link time new------------------------
    //map key=mencoding+kdnumber+areaname value=map<month,linktime>
//    public int getTjForK16ConnectCountNew_Count(String sn,String k16sn,String k16phonenumber,
//    		String k16buytime1,String k16buytime2,String kdnumber,String areaid,String usertype,String... year)
//    {
//    	//加数据权限 通过传递的SN集合判断用户能够取得的数据
//		List<TTjK16LinkTimeVo> t=new ArrayList<TTjK16LinkTimeVo>();
//		TTjK16LinkTimeVo temp=null;
//		int iCount=0;
//    	try {
//			
//			switch(year.length)
//			{
//			   case 2:
//				   this.sql="select count(a.aa) from (SELECT t.mencoding aa FROM t_tj_k16linktime t,t_tel_device tt where t.mencoding=tt.devicesn and t.cyear='"+year[0]+"' and t.cmonth='"+year[1]+"' ";
//				   if(k16sn != null && !"".equals(k16sn))
//					   this.sql += " and t.mencoding like '%"+k16sn+"%'";
//				   if(k16phonenumber != null && !"".equals(k16phonenumber))
//					   this.sql += " and t.telnumber like '%"+k16phonenumber+"%'";
//				   if(k16buytime1 != null && !"".equals(k16buytime1))
//					   this.sql += " and t.createtime > '"+k16buytime1+"'";
//				   if(k16buytime2 != null && !"".equals(k16buytime2))
//					   this.sql += " and t.createtime < '"+k16buytime2+"'";
//				   //add kdnumber
//				   if(kdnumber != null && !"".equals(kdnumber))
//					   this.sql += " and t.kdnumber like '%"+kdnumber+"%'";
//				   //add usertype area
//				   if(areaid != null && !"".equals(areaid))
//					   this.sql += " and t.areaname='"+areaid+"'";
//				   if(usertype != null && !"".equals(usertype))
//					   this.sql += " and t.user_type='"+usertype+"'";
//				   if(sn != null && sn.length()>0)
//					   this.sql += " and t.mencoding in ("+sn+")";
//				   this.sql += " group by t.mencoding,t.kdnumber,t.areaname,t.cday ) a";
//				   break;
//			   case 1:
//				   this.sql=" SELECT cout(t.mencoding) FROM t_tj_k16linktime t,t_tel_device tt where t.mencoding=tt.devicesn and t.cyear='"+year[0]+"' ";
//				   if(k16sn != null && !"".equals(k16sn))
//					   this.sql += " and t.mencoding like '%"+k16sn+"%'";
//				   if(k16phonenumber != null && !"".equals(k16phonenumber))
//					   this.sql += " and t.telnumber like '%"+k16phonenumber+"%'";
//				   if(k16buytime1 != null && !"".equals(k16buytime1))
//					   this.sql += " and t.createtime > '"+k16buytime1+"'";
//				   if(k16buytime2 != null && !"".equals(k16buytime2))
//					   this.sql += " and t.createtime < '"+k16buytime2+"'";
//				   //add kdnumber
//				   if(kdnumber != null && !"".equals(kdnumber))
//					   this.sql += " and t.kdnumber like '%"+kdnumber+"%'";
//				   //add usertype area
//				   if(areaid != null && !"".equals(areaid))
//					   this.sql += " and t.areaname='"+areaid+"'";
//				   if(usertype != null && !"".equals(usertype))
//					   this.sql += " and t.user_type='"+usertype+"'";
//				   if(sn != null && sn.length()>0)
//					   this.sql += " and t.mencoding in ("+sn+")";
//				   this.sql += " group by t.mencoding,t.cmonth ) a";
//				   break;
//			   default:
//				   break;
//			}
//			logger.info("getTjForK16ConnectCount_Count excute: " +sql);
//	    	this.rs1=stmt.executeQuery(sql);
//	    	if(rs1.next())
//	    	{
//	    		iCount=rs1.getInt(1);
//	    	}     	
//    	} catch (Exception e) {
//			e.printStackTrace();
//		}
//    	
//        return iCount;
//    }
    
    
    //----------------------------0618 k16 link time------------------------
    //----------------------------modify 1025 add user_type areaname------------------------
//    public List<TTjK16LinkTimeVo> getTjForK16ConnectCount(String sn,String k16sn,String k16phonenumber,
//    		String k16buytime1,String k16buytime2,String kdnumber,String areaid,String usertype,String... year)
//    {
//    	//加数据权限 通过传递的SN集合判断用户能够取得的数据
//		List<TTjK16LinkTimeVo> t=new ArrayList<TTjK16LinkTimeVo>();
//		TTjK16LinkTimeVo temp=null;
//    	try {
//			
//			switch(year.length)
//			{
//			   case 2:
//				   this.sql="select * from (SELECT IFNULL(mencoding,'unknown'),telnumber,IFNULL(kdnumber,''),createtime,areaname,user_type," +
//				   		"cday,sum(linktime) a FROM t_tj_k16linktime t where  cyear='"+year[0]+"' and cmonth='"+year[1]+"' ";
//				   if(k16sn != null && !"".equals(k16sn))
//					   this.sql += " and mencoding like '%"+k16sn+"%'";
//				   if(k16phonenumber != null && !"".equals(k16phonenumber))
//					   this.sql += " and telnumber like '%"+k16phonenumber+"%'";
//				   if(k16buytime1 != null && !"".equals(k16buytime1))
//					   this.sql += " and createtime > '"+k16buytime1+"'";
//				   if(k16buytime2 != null && !"".equals(k16buytime2))
//					   this.sql += " and createtime < '"+k16buytime2+"'";
//				   //add kdnumber
//				   if(kdnumber != null && !"".equals(kdnumber))
//					   this.sql += " and kdnumber like '%"+kdnumber+"%'";
//				   //add usertype area
//				   if(areaid != null && !"".equals(areaid))
//					   this.sql += " and areaname='"+areaid+"'";
//				   if(usertype != null && !"".equals(usertype))
//					   this.sql += " and user_type='"+usertype+"'";
//				   if(sn != null && sn.length()>0)
//					   this.sql += " and mencoding in ("+sn+")";
//				   this.sql += " group by mencoding,kdnumber,areaname,cday ) a";
//				   break;
//			   case 1:
//				   this.sql=" SELECT IFNULL(mencoding,'unknown'),telnumber,IFNULL(kdnumber,''),createtime,areaname,user_type,cmonth," +
//				   		"sum(linktime) a FROM t_tj_k16linktime t where cyear='"+year[0]+"' ";
//				   if(k16sn != null && !"".equals(k16sn))
//					   this.sql += " and mencoding like '%"+k16sn+"%'";
//				   if(k16phonenumber != null && !"".equals(k16phonenumber))
//					   this.sql += " and telnumber like '%"+k16phonenumber+"%'";
//				   if(k16buytime1 != null && !"".equals(k16buytime1))
//					   this.sql += " and createtime > '"+k16buytime1+"'";
//				   if(k16buytime2 != null && !"".equals(k16buytime2))
//					   this.sql += " and createtime < '"+k16buytime2+"'";
//				   //add kdnumber
//				   if(kdnumber != null && !"".equals(kdnumber))
//					   this.sql += " and kdnumber like '%"+kdnumber+"%'";
//				   //add usertype area
//				   if(areaid != null && !"".equals(areaid))
//					   this.sql += " and areaname='"+areaid+"'";
//				   if(usertype != null && !"".equals(usertype))
//					   this.sql += " and user_type='"+usertype+"'";
//				   if(sn != null && sn.length()>0)
//					   this.sql += " and mencoding in ("+sn+")";
//				   this.sql += " group by mencoding,cmonth ) a";
//				   break;
//			   default:
//				   break;
//			}
//			logger.info("getTjForK16ConnectCount excute: " +sql);
//	    	this.rs1=stmt.executeQuery(sql);
//	    	while(rs1.next())
//	    	{
//	    	   temp=new TTjK16LinkTimeVo();
//	    	   temp.setMencoding(rs1.getString(1));
//	    	   temp.setTelnumber(rs1.getString(2));
//	    	   temp.setKdnumber(this.getString(o[2]));
//	    	   temp.setCreatetime(rs1.getDate(4));
//	    	   temp.setAreaname(rs1.getString(5));
//	    	   temp.setUser_type(rs1.getInt(6));
//	    	   temp.setCmonth(rs1.getString(7));
//	    	   temp.setLinktime(rs1.getInt(8));
//	    	   t.add(temp);
//	    	}    	
//    	} catch (Exception e) {
//			e.printStackTrace();
//		}
//    	
//        return t;
//    }
    //add 1118 get no linktime sn
//    public List<TTjK16LinkTimeVo> getNoLinkTimeSn(Page page,boolean isCount,String snStr)
//    {
//		List<TTjK16LinkTimeVo> t=new ArrayList<TTjK16LinkTimeVo>();
//		TTjK16LinkTimeVo temp=null;
//		if(snStr != null && !snStr.equals("")){
//    	try {
//			
//			this.sql="select distinct nc.mencoding from news_clientinfo nc where nc.mencoding!='' and nc.mencoding not in ("+snStr+")";
//			if(!isCount){
//				sql+=" limit "+((Integer.parseInt(page.getPageno())-1)*Integer.parseInt(page.getRowppage()))+","+Integer.parseInt(page.getRowppage());
//			}
//			logger.info("getNoLinkTimeSn excute: " +sql);
//	    	this.rs1=stmt.executeQuery(sql);
//	    	  sql="select devicesn,telnumber,kdnumber,createtime,user_type,banknumber,servernumber,callcenter,callarea,yyt,servertx,serveraction,priceaction,productname,cname,jx,cstatus,pricename,oktime,note,cempname,caddress,qqh,relationnumber,serverarea,serverqy,xzq,cinfo,ckeyword,creleation,fzman,fzdepartment,validtime,notvalidtime,groupnote,kdsl from t_tel_device where devicesn=?";
//	    	prep2=conn.prepareStatement(sql);	 
//	    	while(rs1.next())
//	    	{
//	    		prep2.setString(1, rs1.getString(1));
//				rs2=prep2.executeQuery();
//				if(rs2.next()){
//				   temp=new TTjK16LinkTimeVo();
//				   temp.setMencoding(rs2.getString(1));
//				   temp.setTelnumber(rs2.getString(2));
//				   temp.setKdnumber(rs2.getString(3));
//				   temp.setCreatetime(rs2.getDate(4));
//				   temp.setAreaname("");
//				   temp.setUser_type(rs2.getInt(5));
//				   temp.setCmonth("");
//				   temp.setLinktime(0);
//				   temp.setBanknumber(rs2.getString(6));
//		    	   temp.setServernumber(rs2.getString(7));
//		    	   temp.setCallcenter(rs2.getString(8));
//		    	   temp.setCallarea(rs2.getString(9));
//		    	   temp.setYyt(rs2.getString(10));
//		    	   temp.setServertx(rs2.getString(11));
//		    	   temp.setServeraction(rs2.getString(12));
//		    	   temp.setPriceaction(rs2.getString(13));
//		    	   temp.setProductname(rs2.getString(14));
//		    	   temp.setCname(rs2.getString(15));
//		    	   temp.setJx(rs2.getString(16));
//		    	   temp.setCstatus(rs2.getString(17));
//		    	   temp.setPricename(rs2.getString(18));
//		    	   temp.setOktime(rs2.getDate(19));
//		    	   temp.setNote(rs2.getString(20));
//		    	   temp.setCempname(rs2.getString(21));
//		    	   temp.setCaddress(rs2.getString(22));
//		    	   temp.setQqh(rs2.getString(23));
//		    	   temp.setRelationnumber(rs2.getString(24));
//		    	   temp.setServerarea(rs2.getString(25));
//		    	   temp.setServerqy(rs2.getString(26));
//		    	   temp.setXzq(rs2.getString(27));
//		    	   temp.setCinfo(rs2.getString(28));
//		    	   temp.setCkeyword(rs2.getString(29));
//		    	   temp.setCreleation(rs2.getString(30));
//		    	   temp.setFzman(rs2.getString(31));
//		    	   temp.setFzdepartment(rs2.getString(32));
//		    	   temp.setValidtime(rs2.getDate(33));
//		    	   temp.setNotvalidtime(rs2.getDate(34));
//		    	   temp.setGroupnote(rs2.getString(35));
//		    	   temp.setKdsl(rs2.getString(36));
//				   t.add(temp);
//				}else{
//				   temp=new TTjK16LinkTimeVo();
//				   temp.setMencoding(rs1.getString(1));
//				   temp.setTelnumber("");
//				   temp.setKdnumber("");
//				   temp.setCreatetime(null);
//				   temp.setAreaname("");
//				   temp.setUser_type(null);
//				   temp.setCmonth("");
//				   temp.setLinktime(0);
//				   t.add(temp);
//				}
//	    	}    	
//    	} catch (Exception e) {
//			e.printStackTrace();
//		}
//    	
//		}
//        return t;
//    }
//    
  //add 1118 get no linktime sn
//    public int getNoLinkTimeSn_Count(String snStr)
//    {
//		List<TTjK16LinkTimeVo> t=new ArrayList<TTjK16LinkTimeVo>();
//		TTjK16LinkTimeVo temp=null;
//		int iCount=0;
//		if(snStr != null && !snStr.equals("")){
//    	try {
//			
//			this.sql="select count(distinct nc.mencoding) from news_clientinfo nc where nc.mencoding!='' and nc.mencoding not in ("+snStr+")";
//			logger.info("getNoLinkTimeSn_Count excute: " +sql);
//	    	this.rs1=stmt.executeQuery(sql);
//	    	if(rs1.next())
//	    	{
//	    		iCount=rs1.getInt(1);
//	    	}    	
//    	} catch (Exception e) {
//			e.printStackTrace();
//		}
//    	
//		}
//        return iCount;
//    }
    
    //取得所有有连接时长的SN集合
//    public String getLinkTimeSnStr(String... year)
//    {
//		String snStr = "";
//		TTjK16LinkTimeVo temp=null;
//    	try {
//			
//			switch(year.length)
//			{
//			   case 2:
//				   this.sql="select distinct mencoding from t_tj_k16linktime where cyear='"+year[0]+"' and cmonth='"+year[1]+"' ";
//				   break;
//			   case 1:
//				   this.sql="select distinct mencoding from t_tj_k16linktime where cyear='"+year[0]+"' ";
//				   break;
//			   default:
//				   break;
//			}
//			logger.info("getLinkTimeSnStr excute: " +sql);
//	    	this.rs1=stmt.executeQuery(sql);
//	    	
//	    	String sn = null;
//			while(rs1.next()){
//				sn=rs1.getString(1);
//				snStr+="'"+sn+"',";
//			}
//			if(!"".equals(snStr)){
//				snStr=snStr.substring(0, snStr.length()-1);
//        	}
//			
//    	} catch (Exception e) {
//			e.printStackTrace();
//		}
//    	
//        return snStr;
//    }
    
    //----------------------------0317 platform user------------------------
    public List<TTjPltfmActUser> findTTjPltfmActUser(String... year) {
    	List<TTjPltfmActUser> t=new ArrayList<TTjPltfmActUser>();
    	TTjPltfmActUser temp=null;
    	try {
			
			switch(year.length)
			{
			   case 4:
				   this.sql=" select mpaltform,IFNULL(ciparea,'unknown'),chour,count(id) as dd from t_tj_pltfmactuser " +
	   			    "  where cyear='"+year[0]+"' and cmonth='"+year[1]+"' and cday='"+year[2]+"' ";
				   if(year[3]!=null && !year[3].equals(""))
					   sql = sql+" and mpaltform='"+year[3]+"' group by chour,ciparea order by mpaltform,chour,ciparea";
				   else
					   sql = sql+"group by chour,ciparea order by mpaltform,chour,ciparea";
				   break;
			   case 3:
				   this.sql=" select mpaltform,IFNULL(ciparea,'unknown'),cday,count(id) as dd from t_tj_pltfmactuser " +
			            "  where cyear='"+year[0]+"' and cmonth='"+year[1]+"' ";
				   if(year[2]!=null && !year[2].equals(""))
					   sql = sql+" and mpaltform='"+year[2]+"' group by ciparea,cday order by cday,ciparea";
				   else
					   sql = sql+"group by mpaltform,ciparea,cday order by mpaltform,chour,ciparea";
				   break;
			   case 2:
				   this.sql=" select mpaltform,IFNULL(ciparea,'unknown'),cmonth,count(id) as dd from t_tj_pltfmactuser " +
		            "  where cyear='"+year[0]+"' ";	
				   if(year[1]!=null && !year[1].equals(""))
					   sql = sql+" and mpaltform='"+year[1]+"' group by ciparea,cmonth order by cmonth,ciparea";
				   else
					   sql = sql+"group by mpaltform,ciparea,cmonth order by mpaltform,cmonth,ciparea";
				   break;
			   default:
				   break;
			}
			logger.info("findTTjPltfmActUser excute: " +sql);
			List<Object[]> tempp=this.em.createNativeQuery(sql).getResultList();
			for(Object[]o:tempp)
			{
	    	
	    	   temp=new TTjPltfmActUser();
	    	   temp.setMpaltform(this.getString(o[0]));
	    	   temp.setCiparea(this.getString(o[1]));
	    	   temp.setCmonth(this.getString(o[2]));
	    	   temp.setUsernumber(this.getInteger(o[3]));
	    	   t.add(temp);
	    	}    	
    	} catch (Exception e) {
			e.printStackTrace();
		}
    	
        return t;
    }
    //----------------------------0318 channle platform user------------------------
    public List<TTjPltfmActUser> findTTjChlfmActUser(String... year) {
    	List<TTjPltfmActUser> t=new ArrayList<TTjPltfmActUser>();
    	TTjPltfmActUser temp=null;
    	try {
			
			switch(year.length)
			{
			   case 4:
				   this.sql=" select mpaltform,IFNULL(magent,'no channel'),chour,count(id) as dd from t_tj_pltfmactuser " +
	   			    "  where cyear='"+year[0]+"' and cmonth='"+year[1]+"' and cday='"+year[2]+"' ";
				   if(year[3]!=null && !year[3].equals(""))
					   sql = sql+" and mpaltform='"+year[3]+"' group by chour,magent order by mpaltform,chour,magent";
				   else
					   sql = sql+"group by chour,magent order by mpaltform,chour,magent";
				   break;
			   case 3:
				   this.sql=" select mpaltform,IFNULL(magent,'no channel'),cday,count(id) as dd from t_tj_pltfmactuser " +
			            "  where cyear='"+year[0]+"' and cmonth='"+year[1]+"' ";
				   if(year[2]!=null && !year[2].equals(""))
					   sql = sql+" and mpaltform='"+year[2]+"' group by magent,cday order by cday,magent";
				   else
					   sql = sql+"group by mpaltform,magent,cday order by mpaltform,chour,magent";
				   break;
			   case 2:
				   this.sql=" select mpaltform,IFNULL(magent,'no channel'),cmonth,count(id) as dd from t_tj_pltfmactuser " +
		            "  where cyear='"+year[0]+"' ";	
				   if(year[1]!=null && !year[1].equals(""))
					   sql = sql+" and mpaltform='"+year[1]+"' group by magent,cmonth order by cmonth,magent";
				   else
					   sql = sql+"group by mpaltform,magent,cmonth order by mpaltform,cmonth,magent";
				   break;
			   default:
				   break;
			}
			logger.info("findTTjPltfmActUser excute: " +sql);
			List<Object[]> tempp=this.em.createNativeQuery(sql).getResultList();
			for(Object[]o:tempp)
			{
	    	   temp=new TTjPltfmActUser();
	    	   temp.setMpaltform(this.getString(o[0]));
	    	   temp.setCiparea(this.getString(o[1]));
	    	   temp.setCmonth(this.getString(o[2]));
	    	   temp.setUsernumber(this.getInteger(o[3]));
	    	   t.add(temp);
	    	}    	
    	} catch (Exception e) {
			e.printStackTrace();
		}
    	
        return t;
    }
    
    public List<DataMap> getAllUserPlatform()
    {
    	this.sql = "SELECT distinct mpaltform FROM news_clientinfo t where mpaltform!=''";
    	try {
			return this.queryALLResultSet(sql);
         } catch (Exception e) {
         	logger.info(" getAllUserPlatform fail !!!" +e.getMessage());
            return null;
         }
    }
    
    //----------------------------0322 channel access------------------------
    //modify 0816 add data permission
    public List<TTjChannelsAccess> findTTjChannelsAccess(String empids,String... year) {
    	List<TTjChannelsAccess> t=new ArrayList<TTjChannelsAccess>();
    	TTjChannelsAccess temp=null;
    	try {
			
			switch(year.length)
			{
			   case 2:
				   this.sql=" SELECT ch_name,cday,accessnumber FROM t_tj_channelsaccess t " +
	   			    "  where cyear='"+year[0]+"' and cmonth='"+year[1]+"' ";
				   if(empids != null && empids.length()>0)
					   this.sql += " and channel_id in (select channel_id from t_user_channels where employee_id in ("+empids+"))";
				   break;
			   case 1:
				   this.sql=" SELECT ch_name,cmonth,sum(accessnumber) a FROM t_tj_channelsaccess t " +
			            "  where cyear='"+year[0]+"' ";
				   if(empids != null && empids.length()>0)
					   this.sql += " and channel_id in (select channel_id from t_user_channels where employee_id in ("+empids+"))";
				   this.sql += " group by channel_id,cmonth order by a desc,cmonth";
				   break;
			   default:
				   break;
			}
			logger.info("findTTjChannelsAccess excute: " +sql);
	    	List<Object[]> tempp=this.em.createNativeQuery(sql).getResultList();
	    	for(Object[]o:tempp)
	    	{
	    	   temp=new TTjChannelsAccess();
	    	   temp.setCh_name(this.getString(o[0]));
	    	   temp.setCmonth(this.getString(o[1]));
	    	   temp.setAccessnumber(this.getInteger(o[2]));
	    	   t.add(temp);
	    	}    	
    	} catch (Exception e) {
			e.printStackTrace();
		}
    	
        return t;
    }
    
    //----------------------------0706 channel ad access------------------------
    //栏目广告访问数统计,取广告对应栏目的访问数,先去广告对应普通栏目的访问数,再取最后一级栏目的访问数,如果有相同的广告需要把访问数相加
    public List<TTjAdsAccess> findTTjChannelAdsAccess(String userids,String... year) {
    	List<TTjAdsAccess> t_normal=new ArrayList<TTjAdsAccess>();
    	List<TTjAdsAccess> t_last=new ArrayList<TTjAdsAccess>();
    	TTjAdsAccess temp=null;
    	try {
			
			switch(year.length)
			{
			   case 2:
				   this.sql=" select na.adid,IFNULL(na.adtitle,'no name'),t.cday,t.accessnumber from news_ads na,news_extends_firstchannel_ads nefa," +
				   		"t_tj_channelsaccess t,news_extends_firstchannel nef where t.cyear='"+year[0]+"' and t.cmonth='"+year[1]+"' " +
				   		"and na.adtype=1 and nefa.adid=na.adid and nefa.channelid=nef.channelid and t.channel_id=nef.channel_id ";
				   if(userids != null && userids.length()>0)
					   this.sql += " and adid in (select adid from news_ads where adtype=1 and adorder in ("+userids+"))";
				   break;
			   case 1:
				   this.sql=" select na.adid,IFNULL(na.adtitle,'no name'),t.cmonth,sum(t.accessnumber) from news_ads na,news_extends_firstchannel_ads nefa, " +
				   		"t_tj_channelsaccess t,news_extends_firstchannel nef where cyear='"+year[0]+"' " +
				   		"and na.adtype=1 and nefa.adid=na.adid and nefa.channelid=nef.channelid and t.channel_id=nef.channel_id ";
				   if(userids != null && userids.length()>0)
					   this.sql += " and adid in (select adid from news_ads where adtype=1 and adorder in ("+userids+"))";
				   this.sql += " group by na.adtitle,t.cmonth";
				   break;
			   default:
				   break;
			}
			logger.info("findTTjChannelAdsAccess normal excute: " +sql);
	    	List<Object[]> tempp=this.em.createNativeQuery(sql).getResultList();
	    	for(Object[]o:tempp)
	    	{
	    	   temp=new TTjAdsAccess();
	    	   temp.setId(this.getInteger(o[0]));
	    	   temp.setAd_name(this.getString(o[1]));
	    	   temp.setCmonth(this.getString(o[2]));
	    	   temp.setAccessnumber(this.getInteger(o[3]));
	    	   t_normal.add(temp);
	    	}
	    	
	    	//last 
	    	switch(year.length)
			{
			   case 2:
				   this.sql=" select na.adid,IFNULL(na.adtitle,'no name'),t.cday,t.accessnumber from news_ads na,news_extends_channel_ads nefa," +
				   		"t_tj_channelsaccess t,news_extends_channel nef where t.cyear='"+year[0]+"' and t.cmonth='"+year[1]+"' " +
				   		"and na.adtype=1 and nefa.adid=na.adid  and nefa.channleid=nef.channleid and t.channel_id=nef.channel_id ";
				   if(userids != null && userids.length()>0)
					   this.sql += " and adid in (select adid from news_ads where adtype=1 and adorder in ("+userids+"))";
				   break;
			   case 1:
				   this.sql=" select na.adid,IFNULL(na.adtitle,'no name'),t.cmonth,sum(t.accessnumber) from news_ads na,news_extends_channel_ads nefa, " +
				   		"t_tj_channelsaccess t,news_extends_channel nef where cyear='"+year[0]+"' " +
				   		"and na.adtype=1 and nefa.adid=na.adid and nefa.channelid=nef.channelid and t.channel_id=nef.channel_id ";
				   if(userids != null && userids.length()>0)
					   this.sql += " and adid in (select adid from news_ads where adtype=1 and adorder in ("+userids+"))";
				   this.sql += " group by na.adtitle,t.cmonth";
				   break;
			   default:
				   break;
			}
			logger.info("findTTjChannelAdsAccess normal excute: " +sql);
	    	 tempp=this.em.createNativeQuery(sql).getResultList();
	    	for(Object[]o:tempp)
	    	{
	    	   temp=new TTjAdsAccess();
	    	   temp.setId(this.getInteger(o[0]));
	    	   temp.setAd_name(this.getString(o[1]));
	    	   temp.setCmonth(this.getString(o[2]));
	    	   temp.setAccessnumber(this.getInteger(o[3]));
	    	   t_last.add(temp);
	    	}
	    	
    	} catch (Exception e) {
			e.printStackTrace();
		}
    	
    	//合并两个结果集,循环普通栏目广告,与最后一级栏目广告比较,发现id一样的就将访问数相加,否则就加入总结果集,最后一级栏目广告循环完置标记为true,确保只加入一次
    	//也可用set去重
    	List<TTjAdsAccess> t=new ArrayList<TTjAdsAccess>();
    	if(t_normal.size()>0 || t_last.size()>0)
    	{
    		boolean addFlag = false;
    		for(TTjAdsAccess norOne : t_normal)
    		{
    			int idNorOne = norOne.getId();
    			int countNorOne = norOne.getAccessnumber();
    			for(TTjAdsAccess lastOne : t_last)
    			{
    				int idLastOne = lastOne.getId();
        			int countLastOne = lastOne.getAccessnumber();
        			if(idNorOne == idLastOne)
        			{
        				countNorOne += countLastOne;
        				norOne.setAccessnumber(countNorOne);
        			}
        			else
        				if(!addFlag)
        					t.add(lastOne);
        			addFlag = true;
    			}
    			t.add(norOne);
    		}
    	}
        return t;
    }
    
    //----------------------------0323 ad access------------------------
    public List<TTjAdsAccess> findTTjAdsAccess(String userids,String... year) {
    	List<TTjAdsAccess> t=new ArrayList<TTjAdsAccess>();
    	TTjAdsAccess temp=null;
    	try {
			
			switch(year.length)
			{
			   case 2:
				   this.sql=" SELECT IFNULL(ad_name,'no name'),cday,accessnumber FROM t_tj_adsaccess t " +
	   			    "  where cyear='"+year[0]+"' and cmonth='"+year[1]+"' ";
				   if(userids != null && userids.length()>0)
					   this.sql += " and adid in (select adid from news_ads where adtype=2 and adorder in ("+userids+"))";
				   break;
			   case 1:
				   this.sql=" SELECT IFNULL(ad_name,'no name'),cmonth,sum(accessnumber) FROM t_tj_adsaccess t " +
			            "  where cyear='"+year[0]+"' ";
				   if(userids != null && userids.length()>0)
					   this.sql += " and adid in (select adid from news_ads where adtype=2 and adorder in ("+userids+"))";
				   this.sql += " group by ad_name,cmonth";
				   break;
			   default:
				   break;
			}
			logger.info("findTTjAdsAccess excute: " +sql);
	    	List<Object[]> tempp=this.em.createNativeQuery(sql).getResultList();
	    	for(Object[]o:tempp)
	    	{
	    	   temp=new TTjAdsAccess();
	    	   temp.setAd_name(this.getString(o[0]));
	    	   temp.setCmonth(this.getString(o[1]));
	    	   temp.setAccessnumber(this.getInteger(o[2]));
	    	   t.add(temp);
	    	}    	
    	} catch (Exception e) {
			e.printStackTrace();
		}
    	
        return t;
    }
    
  //----------------------------20110720 ad click------------------------
    public List<TTjAdsAccess> findTTjAdsClick(String userids,String... year) {
    	List<TTjAdsAccess> t=new ArrayList<TTjAdsAccess>();
    	TTjAdsAccess temp=null;
    	try {
			
			switch(year.length)
			{
			   case 2:
				   this.sql=" SELECT IFNULL(ad_name,'no name'),cday,clicknumber FROM t_tj_adsclick t " +
	   			    "  where cyear='"+year[0]+"' and cmonth='"+year[1]+"' ";
				   if(userids != null && userids.length()>0)
					   this.sql += " and adid in (select adid from news_ads where adtype=2 and adorder in ("+userids+"))";
				   break;
			   case 1:
				   this.sql=" SELECT IFNULL(ad_name,'no name'),cmonth,sum(clicknumber) FROM t_tj_adsclick t " +
			            "  where cyear='"+year[0]+"' ";
				   if(userids != null && userids.length()>0)
					   this.sql += " and adid in (select adid from news_ads where adtype=2 and adorder in ("+userids+"))";
				   this.sql += " group by ad_name,cmonth";
				   break;
			   default:
				   break;
			}
			logger.info("findTTjAdsClick excute: " +sql);
	    	List<Object[]> tempp=this.em.createNativeQuery(sql).getResultList();
	    	for(Object[]o:tempp)
	    	{
	    	   temp=new TTjAdsAccess();
	    	   temp.setAd_name(this.getString(o[0]));
	    	   temp.setCmonth(this.getString(o[1]));
	    	   temp.setAccessnumber(this.getInteger(o[2]));
	    	   t.add(temp);
	    	}    	
    	} catch (Exception e) {
			e.printStackTrace();
		}
    	
        return t;
    }
    
    //----------------------------0324 top twenty------------------------
    public List<TTjTopTwenty> findTTjTopTwenty(String userids,String newstype,String... year) {
    	List<TTjTopTwenty> t=new ArrayList<TTjTopTwenty>();
    	TTjTopTwenty temp=null;
    	try {
			
			switch(year.length)
			{
			   case 2:
				   this.sql=" SELECT cyear,cmonth,contenttitle,contentsource,newstype,sum(accessnumber) number FROM t_tj_toptwenty t " +
	   			    "  where cyear='"+year[0]+"' and cmonth='"+year[1]+"' ";
				   if(newstype != null && newstype.length()>0)
					   this.sql += " and t.newstype = '"+newstype+"' ";
				   if(userids != null && userids.length()>0)
					   this.sql += " and t.user_id in ("+userids+") ";
				   this.sql += " group by cid,cmonth order by number desc limit 50";
				   break;
			   case 1:
				   this.sql=" SELECT cyear,cmonth,contenttitle,contentsource,newstype,sum(accessnumber) number FROM t_tj_toptwenty t " +
			            "  where cyear='"+year[0]+"' ";
				   if(newstype != null && newstype.length()>0)
					   this.sql += " and t.newstype = '"+newstype+"' ";
				   if(userids != null && userids.length()>0)
					   this.sql += " and t.user_id in ("+userids+") ";
				   this.sql += " group by cid order by number desc limit 50";
				   break;
			   default:
				   break;
			}
			logger.info("findTTjTopTwenty excute: " +sql);
	    	List<Object[]> tempp=this.em.createNativeQuery(sql).getResultList();
	    	for(Object[]o:tempp)
	    	{
	    		temp=new TTjTopTwenty();
	    		temp.setCyear(this.getString(o[0])+InterUtil.rb.getString("src.year"));
	    		if(year.length==2)
	    			temp.setCyear(this.getString(o[0])+InterUtil.rb.getString("src.year")+
	    		this.getString(o[1])+InterUtil.rb.getString("src.month"));
	    		temp.setContenttitle(this.getString(o[2]));
	    		String source = this.getString(o[3]);
	    		if(source == null)
	    			source = "";
	    		temp.setContentsource(source);
	    		String newsType = this.getString(o[4]);
	    		if(newsType.equalsIgnoreCase("news"))          newsType=InterUtil.rb_jsp.getString("newspaper.news");
	    		if(newsType.equalsIgnoreCase("game"))          newsType=InterUtil.rb_jsp.getString("genre.game");
	    		if(newsType.equalsIgnoreCase("song"))          newsType=InterUtil.rb_jsp.getString("genre.song");
	    		if(newsType.equalsIgnoreCase("video"))         newsType=InterUtil.rb_jsp.getString("service.video");
	    		if(newsType.equalsIgnoreCase("ebook"))         newsType=InterUtil.rb_jsp.getString("service.e-book");
	    		if(newsType.equalsIgnoreCase("comic"))         newsType=InterUtil.rb_jsp.getString("ebook.type.comic");
	    		if(newsType.equalsIgnoreCase("magazine"))      newsType=InterUtil.rb_jsp.getString("ebook.type.magazine");
	    		if(newsType.equalsIgnoreCase("cpackage"))      newsType=InterUtil.rb_jsp.getString("service.package");
	    		if(newsType.equalsIgnoreCase("section"))       newsType=InterUtil.rb.getString("src.sectionForReport");
	    		if(newsType.equalsIgnoreCase("image"))         newsType=InterUtil.rb_jsp.getString("genre.image");
	    		if(newsType.equalsIgnoreCase("subject"))       newsType=InterUtil.rb_jsp.getString("service.theme");
	    		if(newsType.equalsIgnoreCase("ad"))            newsType=InterUtil.rb_jsp.getString("channel.ads");
	    		if(newsType.equalsIgnoreCase("question"))      newsType=InterUtil.rb_jsp.getString("channel.question");
	    		if(newsType.equalsIgnoreCase("yellowpage"))    newsType=InterUtil.rb_jsp.getString("channel.yellowpage");
	    		if(newsType.equalsIgnoreCase("hdnews"))        newsType=InterUtil.rb_jsp.getString("channel.hdnews");
	    		temp.setNewstype(newsType);
	    		temp.setAccessnumber(this.getInteger(o[5]));
	    		t.add(temp);
	    	}    	
    	} catch (Exception e) {
			e.printStackTrace();
		}
    	
        return t;
    }
    
    //----------------------------20110221 	constopbyarea------------------------
    public List<TjConstopbyareaVo> findTjConstopbyareaList(String userids,
			String newstype,String... year) {
    	List<TjConstopbyareaVo> t=new ArrayList<TjConstopbyareaVo>();
    	TjConstopbyareaVo temp=null;
    	try {
			
			switch(year.length)
			{
			   case 2:
				   this.sql=" SELECT cyear,cmonth,contenttitle,contentsource,newstype,ifnull(t.areaid,-1),user_id,sum(accessnumber) number FROM t_tj_constopbyarea t left join t_areainfo ta on t.areaid=ta.areaid " +
	   			    "  where cyear='"+year[0]+"' and cmonth='"+year[1]+"' ";
				   if(newstype != null && newstype.length()>0)
					   this.sql += " and t.newstype = '"+newstype+"' ";
				   if(userids != null && userids.length()>0)
					   this.sql += " and t.user_id in ("+userids+") ";
				   this.sql += " group by cid,t.areaid,cmonth order by number desc limit 50";
				   break;
			   case 1:
				   this.sql=" SELECT cyear,cmonth,contenttitle,contentsource,newstype,ifnull(t.areaid,-1),user_id,sum(accessnumber) number FROM t_tj_constopbyarea t left join t_areainfo ta on t.areaid=ta.areaid " +
			            "  where cyear='"+year[0]+"' ";
				   if(newstype != null && newstype.length()>0)
					   this.sql += " and t.newstype = '"+newstype+"' ";
				   if(userids != null && userids.length()>0)
					   this.sql += " and t.user_id in ("+userids+") ";
				   this.sql += " group by cid,t.areaid order by number desc limit 50";
				   break;
			   default:
				   break;
			}
			logger.info("findTjConstopbyareaList excute: " +sql);
	    	List<Object[]> tempp=this.em.createNativeQuery(sql).getResultList();
	    	for(Object[]o:tempp)
	    	{
	    		temp=new TjConstopbyareaVo();
	    		temp.setCyear(this.getString(o[0])+InterUtil.rb.getString("src.year"));
	    		if(year.length==2)
	    			temp.setCyear(this.getString(o[0])+InterUtil.rb.getString("src.year")+
	    		this.getString(o[1])+InterUtil.rb.getString("src.month"));
	    		temp.setContenttitle(this.getString(o[2]));
	    		String source = this.getString(o[3]);
	    		if(source == null)
	    			source = "";
	    		temp.setContentsource(source);
	    		String newsType = this.getString(o[4]);
	    		if(newsType.equalsIgnoreCase("news"))          newsType=InterUtil.rb_jsp.getString("newspaper.news");
	    		if(newsType.equalsIgnoreCase("game"))          newsType=InterUtil.rb_jsp.getString("genre.game");
	    		if(newsType.equalsIgnoreCase("song"))          newsType=InterUtil.rb_jsp.getString("genre.song");
	    		if(newsType.equalsIgnoreCase("video"))         newsType=InterUtil.rb_jsp.getString("service.video");
	    		if(newsType.equalsIgnoreCase("ebook"))         newsType=InterUtil.rb_jsp.getString("service.e-book");
	    		if(newsType.equalsIgnoreCase("comic"))         newsType=InterUtil.rb_jsp.getString("ebook.type.comic");
	    		if(newsType.equalsIgnoreCase("magazine"))      newsType=InterUtil.rb_jsp.getString("ebook.type.magazine");
	    		if(newsType.equalsIgnoreCase("cpackage"))      newsType=InterUtil.rb_jsp.getString("service.package");
	    		if(newsType.equalsIgnoreCase("section"))       newsType=InterUtil.rb.getString("src.sectionForReport");
	    		if(newsType.equalsIgnoreCase("image"))         newsType=InterUtil.rb_jsp.getString("genre.image");
	    		if(newsType.equalsIgnoreCase("subject"))       newsType=InterUtil.rb_jsp.getString("service.theme");
	    		if(newsType.equalsIgnoreCase("ad"))            newsType=InterUtil.rb_jsp.getString("channel.ads");
	    		if(newsType.equalsIgnoreCase("question"))      newsType=InterUtil.rb_jsp.getString("channel.question");
	    		if(newsType.equalsIgnoreCase("yellowpage"))    newsType=InterUtil.rb_jsp.getString("channel.yellowpage");
	    		if(newsType.equalsIgnoreCase("hdnews"))        newsType=InterUtil.rb_jsp.getString("channel.hdnews");
	    		temp.setNewstype(newsType);
	    		temp.setAreaid(this.getInteger(o[5]));
	    		temp.setUserid(this.getString(o[6]));
	    		temp.setAccessnumber(this.getInteger(o[7]));
	    		t.add(temp);
	    	}    	
    	} catch (Exception e) {
			e.printStackTrace();
		}
    	
		return t;
	}
    
  //----------------------------20110221 	adaccessbyarea------------------------
    public List<TjAdaccessbyareaVo> findTjAdaccessbyareaList(String userids,String... year) {
    	List<TjAdaccessbyareaVo> t=new ArrayList<TjAdaccessbyareaVo>();
    	TjAdaccessbyareaVo temp=null;
    	try {
			
			switch(year.length)
			{
			   case 3:
				   this.sql=" SELECT cyear,cmonth,cday,ifnull(t.ad_name,''),ifnull(t.areaid,-1),accessnumber FROM t_tj_adaccessbyarea t left join t_areainfo ta on t.areaid=ta.areaid left join news_ads na on t.adid=na.adid" +
	   			    "  where cyear='"+year[0]+"' and cmonth='"+year[1]+"' and cday='"+year[2]+"'";
				   if(userids != null && userids.length()>0)
					   this.sql += " and na.adorder in ("+userids+") ";
				   this.sql += " order by accessnumber desc limit 50";
				   break;
			   case 2:
				   this.sql=" SELECT cyear,cmonth,cday,ifnull(t.ad_name,''),ifnull(t.areaid,-1),accessnumber FROM t_tj_adaccessbyarea t left join t_areainfo ta on t.areaid=ta.areaid left join news_ads na on t.adid=na.adid" +
	   			    "  where cyear='"+year[0]+"' and cmonth='"+year[1]+"' ";
				   if(userids != null && userids.length()>0)
					   this.sql += " and na.adorder in ("+userids+") ";
				   this.sql += " group by t.adid,t.areaid order by accessnumber desc limit 50";
				   break;
			   case 1:
				   this.sql=" SELECT cyear,cmonth,cday,ifnull(t.ad_name,''),ifnull(t.areaid,-1),sum(accessnumber) number FROM t_tj_adaccessbyarea t left join t_areainfo ta on t.areaid=ta.areaid left join news_ads na on t.adid=na.adid" +
			            "  where cyear='"+year[0]+"' ";
				   if(userids != null && userids.length()>0)
					   this.sql += " and na.adorder in ("+userids+") ";
				   this.sql += " group by t.adid,t.areaid order by number desc limit 50";
				   break;
			   default:
				   break;
			}
			logger.info("findTjAdaccessbyareaList excute: " +sql);
	    	List<Object[]> tempp=this.em.createNativeQuery(sql).getResultList();
	    	for(Object[]o:tempp)
	    	{
	    		temp=new TjAdaccessbyareaVo();
	    		temp.setCyear(this.getString(o[0])+InterUtil.rb.getString("src.year"));
	    		if(year.length==2){
	    			temp.setCyear(this.getString(o[0])+InterUtil.rb.getString("src.year")+
	    		    		this.getString(o[1])+InterUtil.rb.getString("src.month"));
	    		}else if(year.length==3){
	    			temp.setCyear(this.getString(o[0])+InterUtil.rb.getString("src.year")+
	    		    		this.getString(o[1])+InterUtil.rb.getString("src.month")+this.getString(o[2])+InterUtil.rb.getString("src.day"));
	    		}
	    		temp.setAdname(this.getString(o[3]));
	    		temp.setAreaid(this.getInteger(o[4]));
	    		temp.setAccessnumber(this.getInteger(o[5]));
	    		t.add(temp);
	    	}    	
    	} catch (Exception e) {
			e.printStackTrace();
		}
    	
		return t;
	}
    
  //----------------------------20110221 	Channelaccess Top50 ------------------------
    public List<TjChannelaccessVo> findTjChannelaccessTopList(String empids,String... year) {
    	List<TjChannelaccessVo> t=new ArrayList<TjChannelaccessVo>();
    	TjChannelaccessVo temp=null;
    	try {
			
			switch(year.length)
			{
			   case 3:
				   this.sql=" SELECT cyear,cmonth,cday,t.ch_name,t.channel_id,accessnumber FROM t_tj_channelsaccess t " +
	   			    "  where cyear='"+year[0]+"' and cmonth='"+year[1]+"' and cday='"+year[2]+"'";
				   if(empids != null && empids.length()>0)
					   this.sql += " and channel_id in (select channel_id from t_user_channels where employee_id in ("+empids+"))";
				   this.sql += " order by accessnumber desc limit 50";
				   break;
			   case 2:
				   this.sql=" SELECT cyear,cmonth,cday,t.ch_name,t.channel_id,sum(accessnumber) number FROM t_tj_channelsaccess t " +
	   			    "  where cyear='"+year[0]+"' and cmonth='"+year[1]+"' ";
				   if(empids != null && empids.length()>0)
					   this.sql += " and channel_id in (select channel_id from t_user_channels where employee_id in ("+empids+"))";
				   this.sql += " group by t.channel_id order by number desc limit 50";
				   break;
			   case 1:
				   this.sql=" SELECT cyear,cmonth,cday,t.ch_name,t.channel_id,sum(accessnumber) number FROM t_tj_channelsaccess t " +
			            "  where cyear='"+year[0]+"' ";
				   if(empids != null && empids.length()>0)
					   this.sql += " and channel_id in (select channel_id from t_user_channels where employee_id in ("+empids+"))";
				   this.sql += " group by t.channel_id order by number desc limit 50";
				   break;
			   default:
				   break;
			}
			logger.info("findTjChannelaccessTopList excute: " +sql);
	    	List<Object[]> tempp=this.em.createNativeQuery(sql).getResultList();
	    	for(Object[]o:tempp)
	    	{
	    		temp=new TjChannelaccessVo();
	    		temp.setCyear(this.getString(o[0])+InterUtil.rb.getString("src.year"));
	    		if(year.length==2){
	    			temp.setCyear(this.getString(o[0])+InterUtil.rb.getString("src.year")+
	    		    		this.getString(o[1])+InterUtil.rb.getString("src.month"));
	    		}else if(year.length==3){
	    			temp.setCyear(this.getString(o[0])+InterUtil.rb.getString("src.year")+
	    		    		this.getString(o[1])+InterUtil.rb.getString("src.month")+this.getString(o[2])+InterUtil.rb.getString("src.day"));
	    		}
	    		temp.setChname(this.getString(o[3]));
	    		temp.setChannelid(this.getString(o[4]));
	    		temp.setAccessnumber(this.getInteger(o[5]));
	    		t.add(temp);
	    	}    	
    	} catch (Exception e) {
			e.printStackTrace();
		}
    	
		return t;
	}
    
    public String getFullChnameById(String fullname,String channelid)
	{
		String sql = "select channel_name,previous_id from t_channels where channel_id='"+channelid+"'";
		try {
//			DataMap result = this.queryOneRow(sql);
//			fullname = result.getMapData("channel_name")  + "-" + fullname;
//			if(result != null && !result.isEmpty() && !result.getMapData("channel_name").equals("news"))
//			{
//				fullname = getFullChnameById(fullname,result.getMapData("previous_id"));
//			}
			return fullname;
		} catch (Exception e) {
			logger.error(" getFullChnameById fail !!!" +e.getMessage());
			return null;
		}
	}
	
    
   //----------------------------20110223 	chaccess single------------------------
    public List<TjChannelaccessVo> findTjChaccessSingle(String empids,String... year) {
    	List<TjChannelaccessVo> t=new ArrayList<TjChannelaccessVo>();
    	TjChannelaccessVo temp=null;
    	try {
			
			switch(year.length)
			{
			   case 2:
				   this.sql=" SELECT ch_name,cday,channel_id,accessnumber FROM t_tj_chaccess_single t " +
	   			    "  where cyear='"+year[0]+"' and cmonth='"+year[1]+"' ";
				   if(empids != null && empids.length()>0)
					   this.sql += " and channel_id in (select channel_id from t_user_channels where employee_id in ("+empids+"))";
				   this.sql +=" and cday is not null";
				   break;
			   case 1:
				   this.sql=" SELECT ch_name,cmonth,channel_id,accessnumber a FROM t_tj_chaccess_single t " +
			            "  where cyear='"+year[0]+"' ";
				   if(empids != null && empids.length()>0)
					   this.sql += " and channel_id in (select channel_id from t_user_channels where employee_id in ("+empids+"))";
				   this.sql +=" and cday is null group by channel_id,cmonth";
				   break;
			   default:
				   break;
			}
			logger.info("findTjChaccessSingle excute: " +sql);
	    	List<Object[]> tempp=this.em.createNativeQuery(sql).getResultList();
	    	for(Object[]o:tempp)
	    	{
	    	   temp=new TjChannelaccessVo();
	    	   temp.setChname(this.getString(o[0]));
	    	   temp.setCmonth(this.getString(o[1]));
	    	   temp.setChannelid(this.getString(o[2]));
	    	   temp.setAccessnumber(this.getInteger(o[3]));
	    	   t.add(temp);
	    	}    	
    	} catch (Exception e) {
			e.printStackTrace();
		}
    	
        return t;
    }
    
    //----------------------------20110223 	consaccess single------------------------
    public List<TjConstopbyareaVo> findTjConsaccessSingleList(String userids,
			String newstype,String... year) {
    	List<TjConstopbyareaVo> t=new ArrayList<TjConstopbyareaVo>();
    	TjConstopbyareaVo temp=null;
    	try {
			
			switch(year.length)
			{
			   case 2:
				   this.sql=" SELECT cyear,cmonth,contenttitle,contentsource,newstype,user_id,accessnumber FROM t_tj_consaccess_single t " +
	   			    "  where cyear='"+year[0]+"' and cmonth='"+year[1]+"' ";
				   if(newstype != null && newstype.length()>0)
					   this.sql += " and t.newstype = '"+newstype+"' ";
				   if(userids != null && userids.length()>0)
					   this.sql += " and t.user_id in ("+userids+") ";
				   this.sql += " and cday is null group by cid,cmonth limit 50";
				   break;
			   case 1:
				   this.sql=" SELECT cyear,cmonth,contenttitle,contentsource,newstype,user_id,sum(accessnumber) number FROM t_tj_consaccess_single t " +
			            "  where cyear='"+year[0]+"' ";
				   if(newstype != null && newstype.length()>0)
					   this.sql += " and t.newstype = '"+newstype+"' ";
				   if(userids != null && userids.length()>0)
					   this.sql += " and t.user_id in ("+userids+") ";
				   this.sql += " group by cid order by number desc limit 50";
				   break;
			   default:
				   break;
			}
			logger.info("findTjConsaccessSingleList excute: " +sql);
	    	List<Object[]> tempp=this.em.createNativeQuery(sql).getResultList();
	    	for(Object[]o:tempp)
	    	{
	    		temp=new TjConstopbyareaVo();
	    		temp.setCyear(this.getString(o[0])+InterUtil.rb.getString("src.year"));
	    		if(year.length==2)
	    			temp.setCyear(this.getString(o[0])+InterUtil.rb.getString("src.year")+
	    		this.getString(o[1])+InterUtil.rb.getString("src.month"));
	    		temp.setContenttitle(this.getString(o[2]));
	    		String source = this.getString(o[3]);
	    		if(source == null)
	    			source = "";
	    		temp.setContentsource(source);
	    		String newsType = this.getString(o[4]);
	    		if(newsType.equalsIgnoreCase("news"))          newsType=InterUtil.rb_jsp.getString("newspaper.news");
	    		if(newsType.equalsIgnoreCase("game"))          newsType=InterUtil.rb_jsp.getString("genre.game");
	    		if(newsType.equalsIgnoreCase("song"))          newsType=InterUtil.rb_jsp.getString("genre.song");
	    		if(newsType.equalsIgnoreCase("video"))         newsType=InterUtil.rb_jsp.getString("service.video");
	    		if(newsType.equalsIgnoreCase("ebook"))         newsType=InterUtil.rb_jsp.getString("service.e-book");
	    		if(newsType.equalsIgnoreCase("comic"))         newsType=InterUtil.rb_jsp.getString("ebook.type.comic");
	    		if(newsType.equalsIgnoreCase("magazine"))      newsType=InterUtil.rb_jsp.getString("ebook.type.magazine");
	    		if(newsType.equalsIgnoreCase("cpackage"))      newsType=InterUtil.rb_jsp.getString("service.package");
	    		if(newsType.equalsIgnoreCase("section"))       newsType=InterUtil.rb.getString("src.sectionForReport");
	    		if(newsType.equalsIgnoreCase("image"))         newsType=InterUtil.rb_jsp.getString("genre.image");
	    		if(newsType.equalsIgnoreCase("subject"))       newsType=InterUtil.rb_jsp.getString("service.theme");
	    		if(newsType.equalsIgnoreCase("ad"))            newsType=InterUtil.rb_jsp.getString("channel.ads");
	    		if(newsType.equalsIgnoreCase("question"))      newsType=InterUtil.rb_jsp.getString("channel.question");
	    		if(newsType.equalsIgnoreCase("yellowpage"))    newsType=InterUtil.rb_jsp.getString("channel.yellowpage");
	    		if(newsType.equalsIgnoreCase("hdnews"))        newsType=InterUtil.rb_jsp.getString("channel.hdnews");
	    		temp.setNewstype(newsType);
	    		temp.setUserid(this.getString(o[5]));
	    		temp.setAccessnumber(this.getInteger(o[6]));
	    		t.add(temp);
	    	}    	
    	} catch (Exception e) {
			e.printStackTrace();
		}
    	
		return t;
	}
    
  //----------------------------20110223 	k16 appaccess------------------------
    public List<TjK16appaccessVo> findTjK16appaccess(String... year) {
    	List<TjK16appaccessVo> t=new ArrayList<TjK16appaccessVo>();
    	TjK16appaccessVo temp=null;
    	try {
			
			switch(year.length)
			{
			   case 2:
				   this.sql=" SELECT appname,cday,appid,accessclient,accessnumber FROM t_tj_k16_appaccess t " +
	   			    "  where cyear='"+year[0]+"' and cmonth='"+year[1]+"' ";
				   this.sql +=" and cday is not null";
				   break;
			   case 1:
				   this.sql=" SELECT appname,cmonth,appid,accessclient,accessnumber FROM t_tj_k16_appaccess t " +
			            "  where cyear='"+year[0]+"' ";
				   this.sql +=" and cday is null group by appid,cmonth";
				   break;
			   default:
				   break;
			}
			logger.info("findTjK16appaccess excute: " +sql);
	    	List<Object[]> tempp=this.em.createNativeQuery(sql).getResultList();
	    	for(Object[]o:tempp)
	    	{
	    	   temp=new TjK16appaccessVo();
	    	   temp.setAppname(this.getString(o[0]));
	    	   temp.setCmonth(this.getString(o[1]));
	    	   temp.setAppid(this.getString(o[2]));
	    	   temp.setAccessclient(this.getInteger(o[3]));
	    	   temp.setAccessnumber(this.getInteger(o[4]));
	    	   t.add(temp);
	    	}    	
    	} catch (Exception e) {
			e.printStackTrace();
		}
    	
        return t;
    }
    
  //----------------------------20110224 	shareuse------------------------
    public List<TjShareuseVo> findTjShareuse(String... year) {
    	List<TjShareuseVo> t=new ArrayList<TjShareuseVo>();
    	TjShareuseVo temp=null;
    	try {
			
			switch(year.length)
			{
			   case 2:
				   this.sql=" SELECT mplatform,cday,usenumber FROM t_tj_shareuse t " +
	   			    "  where cyear='"+year[0]+"' and cmonth='"+year[1]+"' ";
				   break;
			   case 1:
				   this.sql=" SELECT mplatform,cmonth,sum(usenumber) a FROM t_tj_shareuse t " +
			            "  where cyear='"+year[0]+"' ";
				   this.sql += " group by mplatform,cmonth order by a desc,cmonth";
				   break;
			   default:
				   break;
			}
			logger.info("findTjShareuse excute: " +sql);
	    	List<Object[]> tempp=this.em.createNativeQuery(sql).getResultList();
	    	for(Object[]o:tempp)
	    	{
	    	   temp=new TjShareuseVo();
	    	   temp.setMplatform(this.getString(o[0]));
	    	   temp.setCmonth(this.getString(o[1]));
	    	   temp.setUsenumber(this.getInteger(o[2]));
	    	   t.add(temp);
	    	}    	
    	} catch (Exception e) {
			e.printStackTrace();
		}
    	
        return t;
    }
    
  //----------------------------20110224 	k16 receivefile------------------------
    public List<TjK16receivefileVo> findK16receivefile(String... year) {
    	List<TjK16receivefileVo> t=new ArrayList<TjK16receivefileVo>();
    	TjK16receivefileVo temp=null;
    	try {
			
			switch(year.length)
			{
			   case 2:
				   this.sql=" SELECT cday,filenumber,filesize FROM t_tj_k16_receivefile t" +
	   			    "  where cyear='"+year[0]+"' and cmonth='"+year[1]+"' ";
				   break;
			   case 1:
				   this.sql=" SELECT cmonth,sum(filenumber) a,sum(filesize) FROM t_tj_k16_receivefile t " +
			            "  where cyear='"+year[0]+"' ";
				   this.sql += " group by cmonth order by a desc,cmonth";
				   break;
			   default:
				   break;
			}
			logger.info("findK16receivefile excute: " +sql);
	    	List<Object[]> tempp=this.em.createNativeQuery(sql).getResultList();
	    	for(Object[]o:tempp)
	    	{
	    	   temp=new TjK16receivefileVo();
	    	   temp.setCmonth(this.getString(o[0]));
	    	   temp.setFilenumber(this.getInteger(o[1]));
	    	   temp.setFilesize(this.getInteger(o[2]));
	    	   t.add(temp);
	    	}    	
    	} catch (Exception e) {
			e.printStackTrace();
		}
    	
        return t;
    }
    
  //----------------------------20110225 	msgarrival------------------------
    public List<TjMsgarrivalVo> findTjMsgarrival(String... year) {
    	List<TjMsgarrivalVo> t=new ArrayList<TjMsgarrivalVo>();
    	TjMsgarrivalVo temp=null;
    	try {
			
			switch(year.length)
			{
			   case 2:
				   this.sql=" select ns.msgid,msgmoretext,day(msgtime),count(ncm.msgid) from news_clientgetmsg ncm,news_systempopumsg ns where ncm.msgid=ns.msgid " +
	   			    "  and year(msgtime)='"+year[0]+"' and month(msgtime)='"+year[1]+"' ";
				   this.sql += " group by day(msgtime),msgid";
				   break;
			   case 1:
				   this.sql=" select ns.msgid,msgmoretext,month(msgtime),count(ncm.msgid) from news_clientgetmsg ncm,news_systempopumsg ns where ncm.msgid=ns.msgid " +
			            "  and year(msgtime)='"+year[0]+"' ";
				   this.sql += " group by month(msgtime),msgid";
				   break;
			   default:
				   break;
			}
			logger.info("findTjMsgarrival excute: " +sql);
	    	List<Object[]> tempp=this.em.createNativeQuery(sql).getResultList();
	    	for(Object[]o:tempp)
	    	{
	    	   temp=new TjMsgarrivalVo();
	    	   temp.setMsgid(this.getInteger(o[0]));
	    	   temp.setMsgtext(this.getString(o[1]));
	    	   temp.setCmonth(this.getString(o[2]));
	    	   temp.setArrivenumber(this.getInteger(o[3]));
	    	   t.add(temp);
	    	}    	
    	} catch (Exception e) {
			e.printStackTrace();
		}
    	
        return t;
    }
    
    //----------------------------20110225 	msgread------------------------
    public List<TjMsgarrivalVo> findTjMsgread(String... year) {
    	List<TjMsgarrivalVo> t=new ArrayList<TjMsgarrivalVo>();
    	TjMsgarrivalVo temp=null;
    	try {
			
			switch(year.length)
			{
				case 2:
					this.sql=" SELECT msgid,msgtext,cday,readnumber FROM t_tj_k16_msgread t" +
						"  where cyear='"+year[0]+"' and cmonth='"+year[1]+"' ";
					break;
				case 1:
					this.sql=" SELECT msgid,msgtext,cmonth,sum(readnumber) a FROM t_tj_k16_msgread t " +
			            "  where cyear='"+year[0]+"' ";
					this.sql += " group by msgid,cmonth order by a desc,cmonth";
					break;
				default:
					break;
			}
			logger.info("findTjMsgread excute: " +sql);
	    	List<Object[]> tempp=this.em.createNativeQuery(sql).getResultList();
	    	for(Object[]o:tempp)
	    	{
	    	   temp=new TjMsgarrivalVo();
	    	   temp.setMsgid(this.getInteger(o[0]));
	    	   temp.setMsgtext(this.getString(o[1]));
	    	   temp.setCmonth(this.getString(o[2]));
	    	   temp.setArrivenumber(this.getInteger(o[3]));
	    	   t.add(temp);
	    	}    	
    	} catch (Exception e) {
			e.printStackTrace();
		}
    	
        return t;
    }
    
    public String getFullAreaNameById(String fullname,String areaid)
	{
		String sql = "SELECT * FROM t_areainfo WHERE areaid="+areaid;
		
		try {
//			DataMap result = this.queryOneRow(sql);
//			fullname = result.getMapData("areaname")  + "-" + fullname;
//			if(result != null && !result.isEmpty() && !result.getMapData("upareaid").equals("0"))
//			{
//				fullname = getFullAreaNameById(fullname,result.getMapData("upareaid"));
//			}
			return fullname;
		} catch (Exception e) {
			logger.error(" getFullAreaNameById fail !!!" +e.getMessage());
			return null;
		}
	}
    
    //----------------------------20110228 	k16 videotime------------------------
    public List<TjK16avgtimeVo> findTjk16videotimeList(String... year) {
    	List<TjK16avgtimeVo> t=new ArrayList<TjK16avgtimeVo>();
    	TjK16avgtimeVo temp=null;
    	try {
			
			switch(year.length)
			{
			   case 2:
				   this.sql=" SELECT cday,t.areaid,ta.areaname,videoclient,totalnumber,videotime FROM t_tj_k16_videotime t left join t_areainfo ta on t.areaid=ta.areaid " +
	   			    "  where cyear='"+year[0]+"' and cmonth='"+year[1]+"' ";
				   this.sql += " and cday is not null";
				   break;
			   case 1:
				   this.sql=" SELECT  cmonth,t.areaid,ta.areaname,videoclient,totalnumber,videotime FROM t_tj_k16_videotime t left join t_areainfo ta on t.areaid=ta.areaid " +
			            "  where cyear='"+year[0]+"' ";
				   this.sql += " and cday is null group by t.areaid,cmonth";
				   break;
			   default:
				   break;
			}
			logger.info("findTjk16videotimeList excute: " +sql);
	    	List<Object[]> tempp=this.em.createNativeQuery(sql).getResultList();
	    	for(Object[]o:tempp)
	    	{
	    	   temp=new TjK16avgtimeVo();
	    	   temp.setCmonth(this.getString(o[0]));
	    	   temp.setAreaid(this.getInteger(o[1]));
	    	   temp.setAreaname(this.getString(o[2]));
	    	   temp.setClientcount(this.getInteger(o[3]));
	    	   temp.setCallcount(this.getInteger(o[4]));
	    	   temp.setTotaltime(this.getInteger(o[5]));
	    	   t.add(temp);
	    	}    	
    	} catch (Exception e) {
			e.printStackTrace();
		}
    	
        return t;
    }
    
    //----------------------------20110228 	k16 voicetime------------------------
    public List<TjK16avgtimeVo> findTjk16voicetimeList(String... year) {
    	List<TjK16avgtimeVo> t=new ArrayList<TjK16avgtimeVo>();
    	TjK16avgtimeVo temp=null;
    	try {
			
			switch(year.length)
			{
			   case 2:
				   this.sql=" SELECT cday,t.areaid,ta.areaname,voiceclient,totalnumber,voicetime FROM t_tj_k16_voicetime t left join t_areainfo ta on t.areaid=ta.areaid " +
	   			    "  where cyear='"+year[0]+"' and cmonth='"+year[1]+"' ";
				   this.sql += " and cday is not null";
				   break;
			   case 1:
				   this.sql=" SELECT  cmonth,t.areaid,ta.areaname,voiceclient,totalnumber,voicetime FROM t_tj_k16_voicetime t left join t_areainfo ta on t.areaid=ta.areaid " +
			            "  where cyear='"+year[0]+"' ";
				   this.sql += " and cday is null group by t.areaid,cmonth";
				   break;
			   default:
				   break;
			}
			logger.info("findTjk16voicetimeList excute: " +sql);
	    	List<Object[]> tempp=this.em.createNativeQuery(sql).getResultList();
	    	for(Object[]o:tempp)
	    	{
	    	   temp=new TjK16avgtimeVo();
	    	   temp.setCmonth(this.getString(o[0]));
	    	   temp.setAreaid(this.getInteger(o[1]));
	    	   temp.setAreaname(this.getString(o[2]));
	    	   temp.setClientcount(this.getInteger(o[3]));
	    	   temp.setCallcount(this.getInteger(o[4]));
	    	   temp.setTotaltime(this.getInteger(o[5]));
	    	   t.add(temp);
	    	}    	
    	} catch (Exception e) {
			e.printStackTrace();
		}
    	
        return t;
    }
    
    //----------------------------20110228 	k16 recordtime------------------------
    public List<TjK16avgtimeVo> findTjk16recordtimeList(String... year) {
    	List<TjK16avgtimeVo> t=new ArrayList<TjK16avgtimeVo>();
    	TjK16avgtimeVo temp=null;
    	try {
			
			switch(year.length)
			{
			   case 2:
				   this.sql=" SELECT cday,t.areaid,ta.areaname,recordclient,totalnumber,recordtime FROM t_tj_k16_recordtime t left join t_areainfo ta on t.areaid=ta.areaid " +
	   			    "  where cyear='"+year[0]+"' and cmonth='"+year[1]+"' ";
				   this.sql += " and cday is not null";
				   break;
			   case 1:
				   this.sql=" SELECT  cmonth,t.areaid,ta.areaname,recordclient,totalnumber,recordtime FROM t_tj_k16_recordtime t left join t_areainfo ta on t.areaid=ta.areaid " +
			            "  where cyear='"+year[0]+"' ";
				   this.sql += " and cday is null group by t.areaid,cmonth";
				   break;
			   default:
				   break;
			}
			logger.info("findTjk16voicetimeList excute: " +sql);
	    	List<Object[]> tempp=this.em.createNativeQuery(sql).getResultList();
	    	for(Object[]o:tempp)
	    	{
	    	   temp=new TjK16avgtimeVo();
	    	   temp.setCmonth(this.getString(o[0]));
	    	   temp.setAreaid(this.getInteger(o[1]));
	    	   temp.setAreaname(this.getString(o[2]));
	    	   temp.setClientcount(this.getInteger(o[3]));
	    	   temp.setCallcount(this.getInteger(o[4]));
	    	   temp.setTotaltime(this.getInteger(o[5]));
	    	   t.add(temp);
	    	}    	
    	} catch (Exception e) {
			e.printStackTrace();
		}
    	
        return t;
    }
    
    //----------------------------20110228 	k16 specialtime------------------------
    public List<TjK16avgtimeVo> findTjk16specialtimeList(String... year) {
    	List<TjK16avgtimeVo> t=new ArrayList<TjK16avgtimeVo>();
    	TjK16avgtimeVo temp=null;
    	try {
			
			switch(year.length)
			{
			   case 2:
				   this.sql=" SELECT cday,t.areaid,ta.areaname,specialclient,totalnumber,specialtime FROM t_tj_k16_specialtime t left join t_areainfo ta on t.areaid=ta.areaid " +
	   			    "  where cyear='"+year[0]+"' and cmonth='"+year[1]+"' ";
				   this.sql += " and cday is not null";
				   break;
			   case 1:
				   this.sql=" SELECT  cmonth,t.areaid,ta.areaname,specialclient,totalnumber,specialtime FROM t_tj_k16_specialtime t left join t_areainfo ta on t.areaid=ta.areaid " +
			            "  where cyear='"+year[0]+"' ";
				   this.sql += " and cday is null group by t.areaid,cmonth";
				   break;
			   default:
				   break;
			}
			logger.info("findTjk16voicetimeList excute: " +sql);
	    	List<Object[]> tempp=this.em.createNativeQuery(sql).getResultList();
	    	for(Object[]o:tempp)
	    	{
	    	   temp=new TjK16avgtimeVo();
	    	   temp.setCmonth(this.getString(o[0]));
	    	   temp.setAreaid(this.getInteger(o[1]));
	    	   temp.setAreaname(this.getString(o[2]));
	    	   temp.setClientcount(this.getInteger(o[3]));
	    	   temp.setCallcount(this.getInteger(o[4]));
	    	   temp.setTotaltime(this.getInteger(o[5]));
	    	   t.add(temp);
	    	}    	
    	} catch (Exception e) {
			e.printStackTrace();
		}
    	
        return t;
    }
    
  //----------------------------20110228 	k16 browsertime------------------------
    public List<TjK16browsertimeVo> findTjk16browsertimeList(String... year) {
    	List<TjK16browsertimeVo> t=new ArrayList<TjK16browsertimeVo>();
    	TjK16browsertimeVo temp=null;
    	try {
			
			switch(year.length)
			{
			   case 2:
				   this.sql=" SELECT cday,t.areaid,ta.areaname,browsernumber FROM t_tj_k16_browsertime t left join t_areainfo ta on t.areaid=ta.areaid " +
	   			    "  where cyear='"+year[0]+"' and cmonth='"+year[1]+"' ";
				   break;
			   case 1:
				   this.sql=" SELECT  cmonth,t.areaid,ta.areaname,sum(browsernumber) a FROM t_tj_k16_browsertime t left join t_areainfo ta on t.areaid=ta.areaid " +
			            "  where cyear='"+year[0]+"' ";
				   this.sql += " group by t.areaid,cmonth order by a desc,cmonth";
				   break;
			   default:
				   break;
			}
			logger.info("findTjk16browsertimeList excute: " +sql);
	    	List<Object[]> tempp=this.em.createNativeQuery(sql).getResultList();
	    	for(Object[]o:tempp)
	    	{
	    	   temp=new TjK16browsertimeVo();
	    	   temp.setCmonth(this.getString(o[0]));
	    	   temp.setAreaid(this.getInteger(o[1]));
	    	   temp.setAreaname(this.getString(o[2]));
	    	   temp.setBrowsernumber(this.getInteger(o[3]));
	    	   t.add(temp);
	    	}    	
    	} catch (Exception e) {
			e.printStackTrace();
		}
    	
        return t;
    }
    
    //----------------------------20110407 	k16 adscalltime------------------------
    public List<TjK16adscalltimeVo> findTjk16adscalltimeList(TjK16adscalltimeVo k16adscalltime,String... year) {
    	List<TjK16adscalltimeVo> t=new ArrayList<TjK16adscalltimeVo>();
    	TjK16adscalltimeVo temp=null;
    	try {
			
			switch(year.length)
			{
			   case 2:
				   this.sql=" SELECT cday,t.areaid,ta.areaname,callnumber,callclient,totalnumber,calltime FROM t_tj_k16_adscalltime t left join t_areainfo ta on t.areaid=ta.areaid " +
	   			    "  where cyear='"+year[0]+"' and cmonth='"+year[1]+"' ";
				   this.sql += " and callnumber like '%"+k16adscalltime.getPhone().trim()+"%'";
				   this.sql += " and cday is not null";
				   break;
			   case 1:
				   this.sql=" SELECT  cmonth,t.areaid,ta.areaname,callnumber,callclient,totalnumber,calltime FROM t_tj_k16_adscalltime t left join t_areainfo ta on t.areaid=ta.areaid " +
			            "  where cyear='"+year[0]+"' ";
				   this.sql += " and callnumber like '%"+k16adscalltime.getPhone().trim()+"%'";
				   this.sql += " and cday is null";
				   break;
			   default:
				   break;
			}
			logger.info("findTjk16adscalltimeList excute: " +sql);
	    	List<Object[]> tempp=this.em.createNativeQuery(sql).getResultList();
	    	for(Object[]o:tempp)
	    	{
	    	   temp=new TjK16adscalltimeVo();
	    	   temp.setCmonth(this.getString(o[0]));
	    	   temp.setAreaid(this.getInteger(o[1]));
	    	   temp.setAreaname(this.getString(o[2]));
	    	   temp.setPhone(this.getString(o[3]));
	    	   temp.setClientcount(this.getInteger(o[4]));
	    	   temp.setCallcount(this.getInteger(o[5]));
	    	   temp.setTotaltime(this.getInteger(o[6]));
	    	   t.add(temp);
	    	}    	
    	} catch (Exception e) {
			e.printStackTrace();
		}
    	
        return t;
    }
    
    //----------------------------0324 new user------------------------
    public List<TTjNewUser> findTTjNewUser(String... year) {
    	List<TTjNewUser> t=new ArrayList<TTjNewUser>();
    	TTjNewUser temp=null;
    	try {
			
			switch(year.length)
			{
			   case 3:
				   this.sql=" select mpaltform,IFNULL(magent,'no channel'),cday,count(id) as dd from t_tj_newuser " +
			            "  where cyear='"+year[0]+"' and cmonth='"+year[1]+"' ";
				   if(year[2]!=null && !year[2].equals(""))
					   sql = sql+" and mpaltform='"+year[2]+"' group by magent,cday order by cday,magent";
				   else
					   sql = sql+"group by mpaltform,magent,cday order by mpaltform,cday,magent";
				   break;
			   case 2:
				   this.sql=" select mpaltform,IFNULL(magent,'no channel'),cmonth,count(id) as dd from t_tj_newuser " +
		            "  where cyear='"+year[0]+"' ";	
				   if(year[1]!=null && !year[1].equals(""))
					   sql = sql+" and mpaltform='"+year[1]+"' group by magent,cmonth order by cmonth,magent";
				   else
					   sql = sql+"group by mpaltform,magent,cmonth order by mpaltform,cmonth,magent";
				   break;
			   default:
				   break;
			}
			logger.info("findTTjNewUser excute: " +sql);
	    	List<Object[]> tempp=this.em.createNativeQuery(sql).getResultList();
	    	for(Object[]o:tempp)
	    	{
	    	   temp=new TTjNewUser();
	    	   temp.setMpaltform(this.getString(o[0]));
	    	   String magent = this.getString(o[1]);
	    	   if(magent == null)
	    		   magent = "";
	    	   temp.setMagent(magent);
	    	   temp.setCmonth(this.getString(o[2]));
	    	   temp.setUsernumber(this.getInteger(o[3]));
	    	   t.add(temp);
	    	}    	
    	} catch (Exception e) {
			e.printStackTrace();
		}
    	
        return t;
    }
    
    //20110822 for sjz new
    //channel access by platform
    public List<TTjChsAccessByPlatform> findTTjChsAccessByPlatform(String empids,String platform,String... year) {
    	List<TTjChsAccessByPlatform> t=new ArrayList<TTjChsAccessByPlatform>();
    	TTjChsAccessByPlatform temp=null;
    	try {
			
			switch(year.length)
			{
			   case 2:
				   this.sql=" SELECT platform,ch_name,cday,accessnumber FROM t_tj_chsbyplatform t " +
			            "  where cyear='"+year[0]+"' and cmonth='"+year[1]+"' ";
				   if(platform!=null && !platform.equals(""))
					   sql += " and platform='"+platform+"' ";
				   if(empids != null && empids.length()>0)
					   this.sql += " and channel_id in (select channel_id from t_user_channels where employee_id in ("+empids+"))";
				   break;
			   case 1:
				   this.sql=" SELECT platform,ch_name,cmonth,sum(accessnumber) a FROM t_tj_chsbyplatform t " +
	   			    "  where cyear='"+year[0]+"' ";
				   if(platform!=null && !platform.equals(""))
					   sql += " and platform='"+platform+"' ";
				   if(empids != null && empids.length()>0)
					   this.sql += " and channel_id in (select channel_id from t_user_channels where employee_id in ("+empids+"))";
				   this.sql += " group by platform,channel_id,cmonth order by a desc,cmonth";
				   break;
//			   case 1:
//				   this.sql=" SELECT ch_name,platform,cmonth,sum(accessnumber) a FROM t_tj_chsbyplatform t " +
//			            "  where cyear='"+year[0]+"' ";
//				   if(empids != null && empids.length()>0)
//					   this.sql += " and channel_id in (select channel_id from t_user_channels where employee_id in ("+empids+"))";
//				   this.sql += " group by channel_id,cmonth order by a desc,cmonth";
//				   break;
			   default:
				   break;
			}
			logger.info("findTTjChsAccessByPlatform excute: " +sql);
	    	List<Object[]> tempp=this.em.createNativeQuery(sql).getResultList();
	    	for(Object[]o:tempp)
	    	{
	    	   temp=new TTjChsAccessByPlatform();
	    	   temp.setPlatform(this.getString(o[0]));
	    	   temp.setCh_name(this.getString(o[1]));
	    	   temp.setCmonth(this.getString(o[2]));
	    	   temp.setAccessnumber(this.getInteger(o[3]));
	    	   t.add(temp);
	    	}    	
    	} catch (Exception e) {
			e.printStackTrace();
		}
    	
        return t;
    }
    
    //channel client by platform
    public List<TTjChsAccessByPlatform> findTTjChsClientByPlatform(String empids,String platform,String... year) {
    	List<TTjChsAccessByPlatform> t=new ArrayList<TTjChsAccessByPlatform>();
    	TTjChsAccessByPlatform temp=null;
    	try {
			
			switch(year.length)
			{
				case 2:
				   this.sql=" SELECT platform,ch_name,cday,clientnumber FROM t_tj_chsbyplatform_client t " +
			            "  where cyear='"+year[0]+"' and cmonth='"+year[1]+"' ";
				   if(platform!=null && !platform.equals(""))
					   sql += " and platform='"+platform+"' ";
				   if(empids != null && empids.length()>0)
					   this.sql += " and channel_id in (select channel_id from t_user_channels where employee_id in ("+empids+"))";
				   break;
			   case 1:
				   this.sql=" SELECT platform,ch_name,cmonth,sum(clientnumber) a FROM t_tj_chsbyplatform_client t " +
	   			    "  where cyear='"+year[0]+"' ";
				   if(platform!=null && !platform.equals(""))
					   sql += " and platform='"+platform+"' ";
				   if(empids != null && empids.length()>0)
					   this.sql += " and channel_id in (select channel_id from t_user_channels where employee_id in ("+empids+"))";
				   this.sql += " group by platform,channel_id,cmonth order by a desc,cmonth";
				   break;
			   default:
				   break;
			}
			logger.info("findTTjChsClientByPlatform excute: " +sql);
	    	List<Object[]> tempp=this.em.createNativeQuery(sql).getResultList();
	    	for(Object[]o:tempp)
	    	{
	    		temp=new TTjChsAccessByPlatform();
	    		temp.setPlatform(this.getString(o[0]));
	    		temp.setCh_name(this.getString(o[1]));
	    		temp.setCmonth(this.getString(o[2]));
	    		temp.setAccessnumber(this.getInteger(o[3]));
	    		t.add(temp);
	    	}    	
    	} catch (Exception e) {
			e.printStackTrace();
		}
    	
        return t;
    }
    
    //content access by platform
    public List<TTjConsAccessByPlatform> findTTjConsAccessByPlatform(String userids,String titleKeyWrd,String newstype,String searchPlatform,
    		String... year)
    {
    	List<TTjConsAccessByPlatform> t=new ArrayList<TTjConsAccessByPlatform>();
    	TTjConsAccessByPlatform temp=null;
    	try {
			
			switch(year.length)
			{
			   case 2:
				   this.sql=" SELECT cyear,cmonth,platform,contenttitle,contentsource,newstype,accessnumber FROM t_tj_consbyplatform t " +
	   			    "where cyear='"+year[0]+"' and cmonth='"+year[1]+"' ";
				   
				   if(titleKeyWrd != null && titleKeyWrd.length()>0)
					   this.sql += " and contenttitle like '%"+titleKeyWrd+"%'";
				   if(newstype != null && newstype.length()>0)
					   this.sql += " and newstype = '"+newstype+"'";
				   if(searchPlatform != null && searchPlatform.length()>0)
					   this.sql += " and platform = '"+searchPlatform+"'";
				   if(userids != null && userids.length()>0)
					   this.sql += " and user_id in ("+userids+")";
				   break;
			   case 1:
				   this.sql=" SELECT cyear,cmonth,platform,contenttitle,contentsource,newstype,sum(accessnumber) FROM t_tj_consbyplatform t " +
			            "  where cyear='"+year[0]+"' ";
				   if(titleKeyWrd != null && titleKeyWrd.length()>0)
					   this.sql += " and contenttitle like '%"+titleKeyWrd+"%'";
				   if(newstype != null && newstype.length()>0)
					   this.sql += " and newstype = '"+newstype+"'";
				   if(searchPlatform != null && searchPlatform.length()>0)
					   this.sql += " and platform = '"+searchPlatform+"'";
				   if(userids != null && userids.length()>0)
					   this.sql += " and user_id in ("+userids+")";
				   this.sql += " group by platform,t.cid,cmonth";
				   break;
			   default:
				   break;
			}
			logger.info("findTTjConsAccessByPlatform excute: " +sql);
	    	List<Object[]> tempp=this.em.createNativeQuery(sql).getResultList();
	    	for(Object[]o:tempp)
	    	{
	    		temp=new TTjConsAccessByPlatform();
	    	   	temp.setCyear(this.getString(o[0])+InterUtil.rb.getString("src.year"));
	    		if(year.length==2)
	    			temp.setCyear(this.getString(o[0])+InterUtil.rb.getString("src.year")+
	    			this.getString(o[1])+InterUtil.rb.getString("src.month"));
	    		temp.setPlatform(this.getString(o[2]));
	    		temp.setContenttitle(this.getString(o[3]));
	    		String source = this.getString(o[4]);
	    		if(source == null)
	    			source = "";
	    		temp.setContentsource(source);
	    		String newsType = this.getString(o[5]);
	    		if(newsType.equalsIgnoreCase("news"))          newsType=InterUtil.rb_jsp.getString("newspaper.news");
	    		if(newsType.equalsIgnoreCase("game"))          newsType=InterUtil.rb_jsp.getString("genre.game");
	    		if(newsType.equalsIgnoreCase("song"))          newsType=InterUtil.rb_jsp.getString("genre.song");
	    		if(newsType.equalsIgnoreCase("video"))         newsType=InterUtil.rb_jsp.getString("service.video");
	    		if(newsType.equalsIgnoreCase("ebook"))         newsType=InterUtil.rb_jsp.getString("service.e-book");
	    		if(newsType.equalsIgnoreCase("comic"))         newsType=InterUtil.rb_jsp.getString("ebook.type.comic");
	    		if(newsType.equalsIgnoreCase("magazine"))      newsType=InterUtil.rb_jsp.getString("ebook.type.magazine");
	    		if(newsType.equalsIgnoreCase("cpackage"))      newsType=InterUtil.rb_jsp.getString("service.package");
	    		if(newsType.equalsIgnoreCase("section"))       newsType=InterUtil.rb.getString("src.sectionForReport");
	    		if(newsType.equalsIgnoreCase("image"))         newsType=InterUtil.rb_jsp.getString("genre.image");
	    		if(newsType.equalsIgnoreCase("subject"))       newsType=InterUtil.rb_jsp.getString("service.theme");
	    		if(newsType.equalsIgnoreCase("ad"))            newsType=InterUtil.rb_jsp.getString("channel.ads");
	    		if(newsType.equalsIgnoreCase("question"))      newsType=InterUtil.rb_jsp.getString("channel.question");
	    		if(newsType.equalsIgnoreCase("yellowpage"))    newsType=InterUtil.rb_jsp.getString("channel.yellowpage");
	    		if(newsType.equalsIgnoreCase("hdnews"))        newsType=InterUtil.rb_jsp.getString("channel.hdnews");
	    		temp.setNewstype(newsType);
	    		temp.setAccessnumber(this.getInteger(o[6]));
	    		t.add(temp);
	    	}    	
    	} catch (Exception e) {
			e.printStackTrace();
		}
    	
        return t;
    }
    
    public List<TTjConsAccessByPlatform> findTTjConsClientByPlatform(String userids,String titleKeyWrd,String newstype,String searchPlatform,
    		String... year)
    {
    	List<TTjConsAccessByPlatform> t=new ArrayList<TTjConsAccessByPlatform>();
    	TTjConsAccessByPlatform temp=null;
    	try {
			
			switch(year.length)
			{
			   case 2:
				   this.sql=" SELECT cyear,cmonth,platform,contenttitle,contentsource,newstype,clientnumber FROM t_tj_consbyplatform_client t " +
	   			    "where cyear='"+year[0]+"' and cmonth='"+year[1]+"' ";
				   
				   if(titleKeyWrd != null && titleKeyWrd.length()>0)
					   this.sql += " and contenttitle like '%"+titleKeyWrd+"%'";
				   if(newstype != null && newstype.length()>0)
					   this.sql += " and newstype = '"+newstype+"'";
				   if(searchPlatform != null && searchPlatform.length()>0)
					   this.sql += " and platform = '"+searchPlatform+"'";
				   if(userids != null && userids.length()>0)
					   this.sql += " and user_id in ("+userids+")";
				   break;
			   case 1:
				   this.sql=" SELECT cyear,cmonth,platform,contenttitle,contentsource,newstype,sum(clientnumber) FROM t_tj_consbyplatform_client t " +
			            "  where cyear='"+year[0]+"' ";
				   if(titleKeyWrd != null && titleKeyWrd.length()>0)
					   this.sql += " and contenttitle like '%"+titleKeyWrd+"%'";
				   if(newstype != null && newstype.length()>0)
					   this.sql += " and newstype = '"+newstype+"'";
				   if(searchPlatform != null && searchPlatform.length()>0)
					   this.sql += " and platform = '"+searchPlatform+"'";
				   if(userids != null && userids.length()>0)
					   this.sql += " and user_id in ("+userids+")";
				   this.sql += " group by platform,t.cid,cmonth";
				   break;
			   default:
				   break;
			}
			logger.info("findTTjConsAccessByPlatform excute: " +sql);
	    	List<Object[]> tempp=this.em.createNativeQuery(sql).getResultList();
	    	for(Object[]o:tempp)
	    	{
	    		temp=new TTjConsAccessByPlatform();
	    	   	temp.setCyear(this.getString(o[0])+InterUtil.rb.getString("src.year"));
	    		if(year.length==2)
	    			temp.setCyear(this.getString(o[0])+InterUtil.rb.getString("src.year")+
	    			this.getString(o[1])+InterUtil.rb.getString("src.month"));
	    		temp.setPlatform(this.getString(o[2]));
	    		temp.setContenttitle(this.getString(o[3]));
	    		String source = this.getString(o[4]);
	    		if(source == null)
	    			source = "";
	    		temp.setContentsource(source);
	    		String newsType = this.getString(o[5]);
	    		if(newsType.equalsIgnoreCase("news"))          newsType=InterUtil.rb_jsp.getString("newspaper.news");
	    		if(newsType.equalsIgnoreCase("game"))          newsType=InterUtil.rb_jsp.getString("genre.game");
	    		if(newsType.equalsIgnoreCase("song"))          newsType=InterUtil.rb_jsp.getString("genre.song");
	    		if(newsType.equalsIgnoreCase("video"))         newsType=InterUtil.rb_jsp.getString("service.video");
	    		if(newsType.equalsIgnoreCase("ebook"))         newsType=InterUtil.rb_jsp.getString("service.e-book");
	    		if(newsType.equalsIgnoreCase("comic"))         newsType=InterUtil.rb_jsp.getString("ebook.type.comic");
	    		if(newsType.equalsIgnoreCase("magazine"))      newsType=InterUtil.rb_jsp.getString("ebook.type.magazine");
	    		if(newsType.equalsIgnoreCase("cpackage"))      newsType=InterUtil.rb_jsp.getString("service.package");
	    		if(newsType.equalsIgnoreCase("section"))       newsType=InterUtil.rb.getString("src.sectionForReport");
	    		if(newsType.equalsIgnoreCase("image"))         newsType=InterUtil.rb_jsp.getString("genre.image");
	    		if(newsType.equalsIgnoreCase("subject"))       newsType=InterUtil.rb_jsp.getString("service.theme");
	    		if(newsType.equalsIgnoreCase("ad"))            newsType=InterUtil.rb_jsp.getString("channel.ads");
	    		if(newsType.equalsIgnoreCase("question"))      newsType=InterUtil.rb_jsp.getString("channel.question");
	    		if(newsType.equalsIgnoreCase("yellowpage"))    newsType=InterUtil.rb_jsp.getString("channel.yellowpage");
	    		if(newsType.equalsIgnoreCase("hdnews"))        newsType=InterUtil.rb_jsp.getString("channel.hdnews");
	    		temp.setNewstype(newsType);
	    		temp.setAccessnumber(this.getInteger(o[6]));
	    		t.add(temp);
	    	}    	
    	} catch (Exception e) {
			e.printStackTrace();
		}
    	
        return t;
    }
    
    public List<DataMap> getAllUserPlatformForNewUser()
    {
    	this.sql = "SELECT distinct mpaltform FROM t_tj_newuser t";
    	try {
			return this.queryALLResultSet(sql);
         } catch (Exception e) {
         	logger.info(" getAllUserPlatformForNewUser fail !!!" +e.getMessage());
            return null;
         }
    }
    
    public List<TTjMobile> findMobile(String year) {
    	List<TTjMobile> t=new ArrayList<TTjMobile>();
    	TTjMobile temp=null;
    	try {
			
		
    	this.sql="  select  ifnull(uaname,'notset') as uaname  , ifnull(pricetype,'notset') as pricetype ,cmonth,sum(downloadnumber) as dd from t_tj_mobile " +
    			" where cyear='"+year+"' group by uaname,pricetype,cmonth order by uaname,pricetype,cmonth ";
    	List<Object[]> tempp=this.em.createNativeQuery(sql).getResultList();
    	for(Object[]o:tempp)
    	{
    	   temp=new TTjMobile();
    	   temp.setUaname(this.getString(o[0]));
    	   temp.setPricetype(this.getString(o[1]));
    	   temp.setCmonth(this.getString(o[2]));
    	   temp.setDownloadnumber(this.getInteger(o[3]));  
    	   t.add(temp);
    	}    	
    	} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
    	
        return t;
    }
    public List<TTjUsernumber> findUsernumber(String year) {
    	List<TTjUsernumber> t=new ArrayList<TTjUsernumber>();
    	TTjUsernumber temp=null;
    	try {
			
		
    	this.sql="  select  ifnull(sname,'notset') as sname , ifnull(pricetype,'notset') as pricetype ,cmonth,sum(downloadnumber) as dd from t_tj_usernumber " +
    			" where cyear='"+year+"' group by sname,pricetype,cmonth order by sname,pricetype,cmonth";
    	List<Object[]> tempp=this.em.createNativeQuery(sql).getResultList();
    	for(Object[]o:tempp)
    	{
    	   temp=new TTjUsernumber();
    	   temp.setSname(this.getString(o[0]));
    	   temp.setPricetype(this.getString(o[1]));
    	   temp.setCmonth(this.getString(o[2]));
    	   temp.setDownloadnumber(this.getInteger(o[3]));  
    	   t.add(temp);
    	}    	
    	} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
    	
        return t;
    }
    public List<TTjInoutuser> findIOuser(String... year) {
    	List<TTjInoutuser> t=new ArrayList<TTjInoutuser>();
    	TTjInoutuser temp=null;
    	try {
			
			
		   switch(year.length)
		   {
		   case 3:
			   this.sql=" select  ifnull(sname,'notset') as sname , ifnull(inorout,'notset') as inorout ,chour,sum(usernumber) as dd from t_tj_inoutuser " +
   			            "  where cyear='"+year[0]+"' and cmonth='"+year[1]+"' and cday='"+year[2]+"'   group by sname,inorout,chour order by sname,inorout,chour";
			   break;
		   case 2:
			   this.sql=" select ifnull(sname,'notset') as sname , ifnull(inorout,'notset') as inorout ,cday,sum(usernumber) as dd from t_tj_inoutuser " +
		            "  where cyear='"+year[0]+"' and cmonth='"+year[1]+"'   group by sname,inorout,cday order by sname,inorout,cday";
			   break;
		   case 1:
			   this.sql=" select  ifnull(sname,'notset') as sname , ifnull(inorout,'notset') as inorout ,cmonth,sum(usernumber) as dd from t_tj_inoutuser " +
	            "  where cyear='"+year[0]+"'   group by sname,inorout,cmonth order by sname,inorout,cmonth";		  
			   break;
		   default:
			   break;
		   
		   }
    	    	
    	List<Object[]> tempp=this.em.createNativeQuery(sql).getResultList();
    	for(Object[]o:tempp)
    	{
    	   temp=new TTjInoutuser();
    	   temp.setSname(this.getString(o[0]));
    	   temp.setInorout(this.getString(o[1]));
    	   temp.setCmonth(this.getString(o[2]));
    	   temp.setUsernumber(this.getInteger(o[3]));
    	   t.add(temp);
    	}    	
    	} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
    	
        return t;
    }
    
    public List<DataMap> findNewsTjMenber(String... year) {
    		   String Rules="";
    		   if("internal".equals(year[(year.length-1)])){
    			   Rules=" and (ciparea like '中国%' or ciparea like '北京%' or ciparea like '天津%' or ciparea like '河北%' " +
			   		" or ciparea like '山西%' or ciparea like '内蒙古%' or ciparea like '辽宁%' or ciparea like '吉林%' " +
			   		" or ciparea like '黑龙江%' or ciparea like '上海%' or ciparea like '江苏%' or ciparea like '浙江%' " +
			   		" or ciparea like '安徽%' or ciparea like '福建%' or ciparea like '江西%' or ciparea like '山东%' " +
			   		" or ciparea like '河南%' or ciparea like '湖北%' or ciparea like '湖南%' or ciparea like '广东%' " +
			   		" or ciparea like '广西%' or ciparea like '海南%' or ciparea like '重庆%' or ciparea like '四川%' " +
			   		" or ciparea like '贵州%' or ciparea like '青海%' or ciparea like '宁夏%' or ciparea like '新疆%' " +
			   		" or ciparea like '甘肃%' or ciparea like '云南%' or ciparea like '西藏%' or ciparea like '陕西%' " +
			   		" or ciparea like '台湾%' or ciparea like '香港%' or ciparea like '澳门%') ";
    		   }else if("abroad".equals(year[(year.length-1)])){
    			   Rules=" and ciparea not like '中国%' and ciparea not like '北京%' and ciparea not like '天津%' and ciparea not like '河北%' " +
			   		" and ciparea not like '山西%' and ciparea not like '内蒙古%' and ciparea not like '辽宁%' and ciparea not like '吉林%' " +
			   		" and ciparea not like '黑龙江%' and ciparea not like '上海%' and ciparea not like '江苏%' and ciparea not like '浙江%' " +
			   		" and ciparea not like '安徽%' and ciparea not like '福建%' and ciparea not like '江西%' and ciparea not like '山东%' " +
			   		" and ciparea not like '河南%' and ciparea not like '湖北%' and ciparea not like '湖南%' and ciparea not like '广东%' " +
			   		" and ciparea not like '广西%' and ciparea not like '海南%' and ciparea not like '重庆%' and ciparea not like '四川%' " +
			   		" and ciparea not like '贵州%' and ciparea not like '青海%' and ciparea not like '宁夏%' and ciparea not like '新疆%' " +
			   		" and ciparea not like '甘肃%' and ciparea not like '云南%' and ciparea not like '西藏%' and ciparea not like '陕西%' " +
			   		" and ciparea not like '台湾%' and ciparea not like '香港%' and ciparea not like '澳门%' ";
    		   }else if("other".equals(year[(year.length-1)])){
    			   Rules=" and ciparea like 'Unknown' and ciparea like '[未知IP0801]'";
    		   }else if("province".equals(year[(year.length-1)])){
    			   Rules="";
    		   }else if(!"".equals(year[(year.length-1)])){
    			   //最后判断不为空时,为省市模糊查询
    			   Rules=" and ciparea like '"+year[(year.length-1)]+"%'";
    		   }
			   switch(year.length)
			   {
			   case 4:
				   this.sql ="select  ntj.ciparea ,ntj.cipcarrer," +
				   		" ifnull((select sum(cnumber) from news_tj_menber where cyear=ntj.cyear and cmonth=ntj.cmonth and cday=ntj.cday and chour=0 and ciparea=ntj.ciparea and cipcarrer=ntj.cipcarrer),0) 0h," +
				   		" ifnull((select sum(cnumber) from news_tj_menber where cyear=ntj.cyear and cmonth=ntj.cmonth and cday=ntj.cday and chour=1 and ciparea=ntj.ciparea and cipcarrer=ntj.cipcarrer),0) 1h," +
				   		" ifnull((select sum(cnumber) from news_tj_menber where cyear=ntj.cyear and cmonth=ntj.cmonth and cday=ntj.cday and chour=2 and ciparea=ntj.ciparea and cipcarrer=ntj.cipcarrer),0) 2h," +
				   		" ifnull((select sum(cnumber) from news_tj_menber where cyear=ntj.cyear and cmonth=ntj.cmonth and cday=ntj.cday and chour=3 and ciparea=ntj.ciparea and cipcarrer=ntj.cipcarrer),0) 3h," +
				   		" ifnull((select sum(cnumber) from news_tj_menber where cyear=ntj.cyear and cmonth=ntj.cmonth and cday=ntj.cday and chour=4 and ciparea=ntj.ciparea and cipcarrer=ntj.cipcarrer),0) 4h," +
				   		" ifnull((select sum(cnumber) from news_tj_menber where cyear=ntj.cyear and cmonth=ntj.cmonth and cday=ntj.cday and chour=5 and ciparea=ntj.ciparea and cipcarrer=ntj.cipcarrer),0) 5h, " +
				   		" ifnull((select sum(cnumber) from news_tj_menber where cyear=ntj.cyear and cmonth=ntj.cmonth and cday=ntj.cday and chour=6 and ciparea=ntj.ciparea and cipcarrer=ntj.cipcarrer),0) 6h, " +
				   		" ifnull((select sum(cnumber) from news_tj_menber where cyear=ntj.cyear and cmonth=ntj.cmonth and cday=ntj.cday and chour=7 and ciparea=ntj.ciparea and cipcarrer=ntj.cipcarrer),0) 7h, " +
				   		" ifnull((select sum(cnumber) from news_tj_menber where cyear=ntj.cyear and cmonth=ntj.cmonth and cday=ntj.cday and chour=8 and ciparea=ntj.ciparea and cipcarrer=ntj.cipcarrer),0) 8h, " +
				   		" ifnull((select sum(cnumber) from news_tj_menber where cyear=ntj.cyear and cmonth=ntj.cmonth and cday=ntj.cday and chour=9 and ciparea=ntj.ciparea and cipcarrer=ntj.cipcarrer),0) 9h, " +
				   		" ifnull((select sum(cnumber) from news_tj_menber where cyear=ntj.cyear and cmonth=ntj.cmonth and cday=ntj.cday and chour=10 and ciparea=ntj.ciparea and cipcarrer=ntj.cipcarrer),0) 10h, " +
				   		" ifnull((select sum(cnumber) from news_tj_menber where cyear=ntj.cyear and cmonth=ntj.cmonth and cday=ntj.cday and chour=11 and ciparea=ntj.ciparea and cipcarrer=ntj.cipcarrer),0) 11h, " +
				   		" ifnull((select sum(cnumber) from news_tj_menber where cyear=ntj.cyear and cmonth=ntj.cmonth and cday=ntj.cday and chour=12 and ciparea=ntj.ciparea and cipcarrer=ntj.cipcarrer),0) 12h, " +
				   		" ifnull((select sum(cnumber) from news_tj_menber where cyear=ntj.cyear and cmonth=ntj.cmonth and cday=ntj.cday and chour=13 and ciparea=ntj.ciparea and cipcarrer=ntj.cipcarrer),0) 13h, " +
				   		" ifnull((select sum(cnumber) from news_tj_menber where cyear=ntj.cyear and cmonth=ntj.cmonth and cday=ntj.cday and chour=14 and ciparea=ntj.ciparea and cipcarrer=ntj.cipcarrer),0) 14h, " +
				   		" ifnull((select sum(cnumber) from news_tj_menber where cyear=ntj.cyear and cmonth=ntj.cmonth and cday=ntj.cday and chour=15 and ciparea=ntj.ciparea and cipcarrer=ntj.cipcarrer),0) 15h, " +
				   		" ifnull((select sum(cnumber) from news_tj_menber where cyear=ntj.cyear and cmonth=ntj.cmonth and cday=ntj.cday and chour=16 and ciparea=ntj.ciparea and cipcarrer=ntj.cipcarrer),0) 16h, " +
				   		" ifnull((select sum(cnumber) from news_tj_menber where cyear=ntj.cyear and cmonth=ntj.cmonth and cday=ntj.cday and chour=17 and ciparea=ntj.ciparea and cipcarrer=ntj.cipcarrer),0) 17h, " +
				   		" ifnull((select sum(cnumber) from news_tj_menber where cyear=ntj.cyear and cmonth=ntj.cmonth and cday=ntj.cday and chour=18 and ciparea=ntj.ciparea and cipcarrer=ntj.cipcarrer),0) 18h, " +
				   		" ifnull((select sum(cnumber) from news_tj_menber where cyear=ntj.cyear and cmonth=ntj.cmonth and cday=ntj.cday and chour=19 and ciparea=ntj.ciparea and cipcarrer=ntj.cipcarrer),0) 19h, " +
				   		" ifnull((select sum(cnumber) from news_tj_menber where cyear=ntj.cyear and cmonth=ntj.cmonth and cday=ntj.cday and chour=20 and ciparea=ntj.ciparea and cipcarrer=ntj.cipcarrer),0) 20h, " +
				   		" ifnull((select sum(cnumber) from news_tj_menber where cyear=ntj.cyear and cmonth=ntj.cmonth and cday=ntj.cday and chour=21 and ciparea=ntj.ciparea and cipcarrer=ntj.cipcarrer),0) 21h, " +
				   		" ifnull((select sum(cnumber) from news_tj_menber where cyear=ntj.cyear and cmonth=ntj.cmonth and cday=ntj.cday and chour=22 and ciparea=ntj.ciparea and cipcarrer=ntj.cipcarrer),0) 22h, " +
				   		" ifnull((select sum(cnumber) from news_tj_menber where cyear=ntj.cyear and cmonth=ntj.cmonth and cday=ntj.cday and chour=23 and ciparea=ntj.ciparea and cipcarrer=ntj.cipcarrer),0) 23h, " +
				   		" sum(cnumber) nn" +
				   		" from news_tj_menber ntj "+
				   		" where ntj.cyear="+year[0]+" and ntj.cmonth="+year[1]+" and ntj.cday="+year[2]+"" +Rules +
				   		" group by ntj.ciparea,ntj.cipcarrer order by ntj.ciparea ,nn desc";
				   break;
			   case 3:
				   this.sql = "select  ntj.ciparea ,ntj.cipcarrer," +
				   		" ifnull((select sum(cnumber) from news_tj_menber where cyear=ntj.cyear and cmonth=ntj.cmonth and cday=1 and ciparea=ntj.ciparea and cipcarrer=ntj.cipcarrer),0) 1th, " +
				   		" ifnull((select sum(cnumber) from news_tj_menber where cyear=ntj.cyear and cmonth=ntj.cmonth and cday=2 and ciparea=ntj.ciparea and cipcarrer=ntj.cipcarrer),0) 2th, " +
				   		" ifnull((select sum(cnumber) from news_tj_menber where cyear=ntj.cyear and cmonth=ntj.cmonth and cday=3 and ciparea=ntj.ciparea and cipcarrer=ntj.cipcarrer),0) 3th, " +
				   		" ifnull((select sum(cnumber) from news_tj_menber where cyear=ntj.cyear and cmonth=ntj.cmonth and cday=4 and ciparea=ntj.ciparea and cipcarrer=ntj.cipcarrer),0) 4th, " +
				   		" ifnull((select sum(cnumber) from news_tj_menber where cyear=ntj.cyear and cmonth=ntj.cmonth and cday=5 and ciparea=ntj.ciparea and cipcarrer=ntj.cipcarrer),0) 5th, " +
				   		" ifnull((select sum(cnumber) from news_tj_menber where cyear=ntj.cyear and cmonth=ntj.cmonth and cday=6 and ciparea=ntj.ciparea and cipcarrer=ntj.cipcarrer),0) 6th, " +
				   		" ifnull((select sum(cnumber) from news_tj_menber where cyear=ntj.cyear and cmonth=ntj.cmonth and cday=7 and ciparea=ntj.ciparea and cipcarrer=ntj.cipcarrer),0) 7th, " +
				   		" ifnull((select sum(cnumber) from news_tj_menber where cyear=ntj.cyear and cmonth=ntj.cmonth and cday=8 and ciparea=ntj.ciparea and cipcarrer=ntj.cipcarrer),0) 8th, " +
				   		" ifnull((select sum(cnumber) from news_tj_menber where cyear=ntj.cyear and cmonth=ntj.cmonth and cday=9 and ciparea=ntj.ciparea and cipcarrer=ntj.cipcarrer),0) 9th, " +
				   		" ifnull((select sum(cnumber) from news_tj_menber where cyear=ntj.cyear and cmonth=ntj.cmonth and cday=10 and ciparea=ntj.ciparea and cipcarrer=ntj.cipcarrer),0) 10th, " +
				   		" ifnull((select sum(cnumber) from news_tj_menber where cyear=ntj.cyear and cmonth=ntj.cmonth and cday=11 and ciparea=ntj.ciparea and cipcarrer=ntj.cipcarrer),0) 11th, " +
				   		" ifnull((select sum(cnumber) from news_tj_menber where cyear=ntj.cyear and cmonth=ntj.cmonth and cday=12 and ciparea=ntj.ciparea and cipcarrer=ntj.cipcarrer),0) 12th, " +
				   		" ifnull((select sum(cnumber) from news_tj_menber where cyear=ntj.cyear and cmonth=ntj.cmonth and cday=13 and ciparea=ntj.ciparea and cipcarrer=ntj.cipcarrer),0) 13th, " +
				   		" ifnull((select sum(cnumber) from news_tj_menber where cyear=ntj.cyear and cmonth=ntj.cmonth and cday=14 and ciparea=ntj.ciparea and cipcarrer=ntj.cipcarrer),0) 14th, " +
				   		" ifnull((select sum(cnumber) from news_tj_menber where cyear=ntj.cyear and cmonth=ntj.cmonth and cday=15 and ciparea=ntj.ciparea and cipcarrer=ntj.cipcarrer),0) 15th, " +
				   		" ifnull((select sum(cnumber) from news_tj_menber where cyear=ntj.cyear and cmonth=ntj.cmonth and cday=16 and ciparea=ntj.ciparea and cipcarrer=ntj.cipcarrer),0) 16th, " +
				   		" ifnull((select sum(cnumber) from news_tj_menber where cyear=ntj.cyear and cmonth=ntj.cmonth and cday=17 and ciparea=ntj.ciparea and cipcarrer=ntj.cipcarrer),0) 17th, " +
				   		" ifnull((select sum(cnumber) from news_tj_menber where cyear=ntj.cyear and cmonth=ntj.cmonth and cday=18 and ciparea=ntj.ciparea and cipcarrer=ntj.cipcarrer),0) 18th, " +
				   		" ifnull((select sum(cnumber) from news_tj_menber where cyear=ntj.cyear and cmonth=ntj.cmonth and cday=19 and ciparea=ntj.ciparea and cipcarrer=ntj.cipcarrer),0) 19th, " +
				   		" ifnull((select sum(cnumber) from news_tj_menber where cyear=ntj.cyear and cmonth=ntj.cmonth and cday=20 and ciparea=ntj.ciparea and cipcarrer=ntj.cipcarrer),0) 20th, " +
				   		" ifnull((select sum(cnumber) from news_tj_menber where cyear=ntj.cyear and cmonth=ntj.cmonth and cday=21 and ciparea=ntj.ciparea and cipcarrer=ntj.cipcarrer),0) 21th, " +
				   		" ifnull((select sum(cnumber) from news_tj_menber where cyear=ntj.cyear and cmonth=ntj.cmonth and cday=22 and ciparea=ntj.ciparea and cipcarrer=ntj.cipcarrer),0) 22th, " +
				   		" ifnull((select sum(cnumber) from news_tj_menber where cyear=ntj.cyear and cmonth=ntj.cmonth and cday=23 and ciparea=ntj.ciparea and cipcarrer=ntj.cipcarrer),0) 23th, " +
				   		" ifnull((select sum(cnumber) from news_tj_menber where cyear=ntj.cyear and cmonth=ntj.cmonth and cday=24 and ciparea=ntj.ciparea and cipcarrer=ntj.cipcarrer),0) 24th, " +
				   		" ifnull((select sum(cnumber) from news_tj_menber where cyear=ntj.cyear and cmonth=ntj.cmonth and cday=25 and ciparea=ntj.ciparea and cipcarrer=ntj.cipcarrer),0) 25th, " +
				   		" ifnull((select sum(cnumber) from news_tj_menber where cyear=ntj.cyear and cmonth=ntj.cmonth and cday=26 and ciparea=ntj.ciparea and cipcarrer=ntj.cipcarrer),0) 26th, " +
				   		" ifnull((select sum(cnumber) from news_tj_menber where cyear=ntj.cyear and cmonth=ntj.cmonth and cday=27 and ciparea=ntj.ciparea and cipcarrer=ntj.cipcarrer),0) 27th, " +
				   		" ifnull((select sum(cnumber) from news_tj_menber where cyear=ntj.cyear and cmonth=ntj.cmonth and cday=28 and ciparea=ntj.ciparea and cipcarrer=ntj.cipcarrer),0) 28th, " +
				   		" ifnull((select sum(cnumber) from news_tj_menber where cyear=ntj.cyear and cmonth=ntj.cmonth and cday=29 and ciparea=ntj.ciparea and cipcarrer=ntj.cipcarrer),0) 29th, " +
				   		" ifnull((select sum(cnumber) from news_tj_menber where cyear=ntj.cyear and cmonth=ntj.cmonth and cday=30 and ciparea=ntj.ciparea and cipcarrer=ntj.cipcarrer),0) 30th, " +
				   		" ifnull((select sum(cnumber) from news_tj_menber where cyear=ntj.cyear and cmonth=ntj.cmonth and cday=31 and ciparea=ntj.ciparea and cipcarrer=ntj.cipcarrer),0) 31th, " +
				   		" sum(cnumber) nn" +
				   		" from news_tj_menber ntj " +
				   		" where ntj.cyear="+year[0]+" and ntj.cmonth="+year[1]+"" +Rules+
				   		" group by ntj.ciparea,ntj.cipcarrer order by ntj.ciparea ,nn desc";
				   break;
			   case 2:
				   this.sql ="select ntj.ciparea ciparea,ntj.cipcarrer cipcarrer,"+
			   		" ifnull((select sum(cnumber) from news_tj_menber where cyear=ntj.cyear and cmonth=1 and ciparea=ntj.ciparea and cipcarrer=ntj.cipcarrer),0) Jan1," +
			   		" ifnull((select sum(cnumber) from news_tj_menber where cyear=ntj.cyear and cmonth=2 and ciparea=ntj.ciparea and cipcarrer=ntj.cipcarrer),0) Feb2," +
			   		" ifnull((select sum(cnumber) from news_tj_menber where cyear=ntj.cyear and cmonth=3 and ciparea=ntj.ciparea and cipcarrer=ntj.cipcarrer),0) Mar3," +
			   		" ifnull((select sum(cnumber) from news_tj_menber where cyear=ntj.cyear and cmonth=4 and ciparea=ntj.ciparea and cipcarrer=ntj.cipcarrer),0) Apr4," +
			   		" ifnull((select sum(cnumber) from news_tj_menber where cyear=ntj.cyear and cmonth=5 and ciparea=ntj.ciparea and cipcarrer=ntj.cipcarrer),0) May5," +
			   		" ifnull((select sum(cnumber) from news_tj_menber where cyear=ntj.cyear and cmonth=6 and ciparea=ntj.ciparea and cipcarrer=ntj.cipcarrer),0) June6,"+
			   		" ifnull((select sum(cnumber) from news_tj_menber where cyear=ntj.cyear and cmonth=7 and ciparea=ntj.ciparea and cipcarrer=ntj.cipcarrer),0) July7,"+
			   		" ifnull((select sum(cnumber) from news_tj_menber where cyear=ntj.cyear and cmonth=8 and ciparea=ntj.ciparea and cipcarrer=ntj.cipcarrer),0) Aug8," +
			   		" ifnull((select sum(cnumber) from news_tj_menber where cyear=ntj.cyear and cmonth=9 and ciparea=ntj.ciparea and cipcarrer=ntj.cipcarrer),0) Sep9," +
			   		" ifnull((select sum(cnumber) from news_tj_menber where cyear=ntj.cyear and cmonth=10 and ciparea=ntj.ciparea and cipcarrer=ntj.cipcarrer),0) Oct10," +
			   		" ifnull((select sum(cnumber) from news_tj_menber where cyear=ntj.cyear and cmonth=11 and ciparea=ntj.ciparea and cipcarrer=ntj.cipcarrer),0) Nov11," +
			   		" ifnull((select sum(cnumber) from news_tj_menber where cyear=ntj.cyear and cmonth=12 and ciparea=ntj.ciparea and cipcarrer=ntj.cipcarrer),0) Dec12," +
			   		" sum(cnumber) nn"+
			   		" from news_tj_menber ntj"+
			   		" where ntj.cyear="+year[0]+""+Rules+
			   		" group by ntj.ciparea,ntj.cipcarrer order by ntj.ciparea ,nn desc";
				   break;
			   default:
				   break;
			   
			   }
	    	 try {
				return  this.queryALLResultSet(sql);
	         } catch (Exception e) {
	         	logger.info(" getPriceAll fail !!!" +e.getMessage());
	            return null;
	         }
	    }
    
    /**
     * 插入日志分析记录
     * @param dataList
     * @return
     * @throws Exception
     */
    public boolean insertAccesslog(List<String> dtimeList,List<String> ipList,List<String> udidList,Map<String,String> iparea_map,Map<String,String> ipcarrer_map){
    	boolean returnState = true;
    	try {
    		
    		this.sql=" insert into news_accesslog (cyear,cmonth,cday,chour,cip,udid,ciparea,cipcarrer) values (?,?,?,?,?,?,?,?)";
    		//this.prep=this.conn.prepareStatement(sql);	
    		Query	query=em.createNativeQuery(sql);
			
//				query.setParameter(1,  organization.getSpcode());
//				query.setParameter(2, groupid);
				
    		int iii=0;
    		int bbb=0;
    		for(int i=0;i<dtimeList.size();i++){
    			query.setParameter(1, Integer.parseInt(dtimeList.get(i).substring(0, 4)));
    			query.setParameter(2, Integer.parseInt(dtimeList.get(i).substring(5, 7)));
    			query.setParameter(3, Integer.parseInt(dtimeList.get(i).substring(8, 10)));
    			query.setParameter(4, Integer.parseInt(dtimeList.get(i).substring(11, 13)));
    			query.setParameter(5, ipList.get(i));
    			query.setParameter(6, udidList.get(i));
    			query.setParameter(7, iparea_map.get(ipList.get(i)));
    			query.setParameter(8, ipcarrer_map.get(ipList.get(i)));
    			//prep.addBatch();
    			iii++;
    			query.executeUpdate();
//    			if(++bbb%100==0){
//    				logger.info(bbb);
//    			}
//    			if(iii>100)
//    			{	
//    				prep.executeBatch();
//    				iii=0;
//    			}
    		}
//    		if(iii>0)
//			{	
//				prep.executeBatch();
//			}
    		
	    	}catch (Exception e) {
	            logger.debug("Error Occur.When execut the sql : "+sql);
	            e.printStackTrace();
	            returnState = false;
			}
	        return returnState;
	}
    
    /**
     * 更新日志分析统计  更新点击量
     * @return
     * @throws Exception 
     */
    public boolean updateTjMenber() throws Exception {
    	boolean returnState = true;
    	try {
    		
    		this.sql="REPLACE INTO news_tj_menber (cyear,cmonth,cday,chour,ciparea,cipcarrer,cnumber) " +
			"(SELECT cyear,cmonth,cday,chour,ciparea,cipcarrer, count(*) as cnumber FROM news_accesslog " +
			" WHERE ciparea is not null AND cipcarrer is not null" +
			" GROUP BY ciparea,cipcarrer,cyear,cmonth,cday,chour)";
    		/* 
    		    //news_tj_menber增加字段cudidnumber 记录活跃用户数
    		    this.sql="REPLACE INTO news_tj_menber (cyear,cmonth,cday,chour,ciparea,cipcarrer,cudidnumber,cnumber) " +
				"(SELECT cyear,cmonth,cday,chour,ciparea,cipcarrer,count(distinct udid) as cudidnumber, count(*) as cnumber FROM news_accesslog " +
				" WHERE ciparea is not null AND cipcarrer is not null" +
				" GROUP BY ciparea,cipcarrer,chour)";*/
    	this.updateNativeQuery(sql);
	    	} catch (Exception e) {
	    		
	            logger.debug("Error Occur.When execut the sql : "+sql);
	            returnState = false;
	            throw new Exception(e.getMessage());
    	}
    	
        return returnState;
		
	}
    
    
	
	
    public String findAllEmpid(String spcodeS) {
		String userids = "";
		try {
	        
			sql="select tu.employee_id from t_employee te join t_user tu on te.employee_id=tu.employee_id where te.sp_code in ("+spcodeS+")";
			List<Object[]> tempp=this.em.createNativeQuery(sql).getResultList();
			String userid=null;
			String empid = null;
			for(Object[]o:tempp){
				empid=this.getString(o[0]);
				userids+="'"+empid+"',";
			}
			if(!"".equals(userids)){
				userids=userids.substring(0, userids.length()-1);
        	}
			//System.out.println("userids:"+userids);
		 }catch (Exception e) {
				logger.error("findAllEmpid fail !!!" + e.getMessage());
				e.printStackTrace();
		}
		return userids;
	}
    
    //根据spcode取sn集合
    public String findAllSnBySpcodes(String spcodeS) {
		String userids = "";
		try {
	        
			sql="select distinct nc.mencoding from t_spcode_rulegroup tsr ,news_groupuserset ng,news_clientinfo nc " +
					"where tsr.spcode in ("+spcodeS+") and tsr.rulegroup =ng.groupruleid and ng.clientid=nc.clientid";
			List<Object[]> tempp=this.em.createNativeQuery(sql).getResultList();
			String sn = null;
			for(Object[]o:tempp){
				sn=this.getString(o[0]);
				userids+="'"+sn+"',";
			}
			if(!"".equals(userids)){
				userids=userids.substring(0, userids.length()-1);
        	}
		 }catch (Exception e) {
				logger.error("findAllSnBySpcodes fail !!!" + e.getMessage());
				e.printStackTrace();
		}
		return userids;
	}

//    private void initJdbcForReport() throws Exception
//    {
//    	this.initRptConnection();
//    }
    
//    private ArrayList queryALLResultSetForReport(String querySql) throws Exception 
//    {
//	    String[] columnName;
//	    ArrayList ListData = new ArrayList();
//	    int columnCount = 0;
//	
//	    try{
//	    	   
//	        rs1 = stmt.executeQuery(querySql);
//	
//	        ResultSetMetaData rsmd = rs1.getMetaData();
//	        int NumCols = rsmd.getColumnCount();
//	        columnName = new String[NumCols];
//	
//	        for (int k = 0; k < NumCols; k++) {
//	            columnName[k] = rsmd.getColumnName(k + 1).toString().toLowerCase();
//	            if(columnName[k].equals(""))
//	            	columnName[k] = rsmd.getColumnLabel(k + 1).toString().toLowerCase();
//	        }
//	
//	        while (rs1.next()) {
//	            int i = 0;
//	            DataMap hash = new DataMap();
//	
//	            for (; i < NumCols; i++) {
//	                String columnValue = rs1.getString(i + 1);
//	                columnValue = (columnValue == null) ? "" : columnValue;
//	                hash.put(columnName[i], columnValue);
//	            }
//	
//	            ListData.add(hash);
//	        }
//	
////	        log.debug("The Query Is Successful and The Begin Row Is ");
//	    } catch (java.sql.SQLException e) {
//	        e.printStackTrace();
//	    } 
//	    return ListData;
//	}

	/*
	 * 实现查询所有符合条件的操作
	 * @Param querySql  查询语句
	 * @return 以Object数组对象返回的查询结果
	 * 修改getColumnName为getColumnLabel 用字段别名作为map里的key
	 */
//    private ArrayList queryALLResultSetByColumnLabelForReport(String querySql) throws Exception 
//    {
//	    String[] columnName;
//	    ArrayList ListData = new ArrayList();
//	    int columnCount = 0;
//	    try{
//	    	   
//	        rs1 = stmt.executeQuery(querySql);
//	        ResultSetMetaData rsmd = rs1.getMetaData();
//	        int NumCols = rsmd.getColumnCount();
//	        columnName = new String[NumCols];
//	        for (int k = 0; k < NumCols; k++) {
//	            columnName[k] = rsmd.getColumnLabel(k + 1).toString().toLowerCase();
//	        }
//	        while (rs1.next()) {
//	            int i = 0;
//	            DataMap hash = new DataMap();
//	            for (; i < NumCols; i++) {
//	                String columnValue = rs1.getString(i + 1);
//	                columnValue = (columnValue == null) ? "" : columnValue;
//	                hash.put(columnName[i], columnValue);
//	            }
//	            ListData.add(hash);
//	        }
////	        log.debug("The Query Is Successful and The Begin Row Is ");
//	    } catch (java.sql.SQLException e) {
//	        e.printStackTrace();
//	    } 
//	    return ListData;
//	}
	
}